<!-- HTML header for doxygen 1.13.2-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.13.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>yyjson: API</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="clipboard.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="cookie.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="doxygen-awesome.css" rel="stylesheet" type="text/css"/>
<link href="doxygen-awesome-sidebar-only.css" rel="stylesheet" type="text/css"/>
<link href="doxygen-awesome-sidebar-only-darkmode-toggle.css" rel="stylesheet" type="text/css"/>
<link href="yyjson-style.css" rel="stylesheet" type="text/css"/>
<!-- css awesome -->
<script type="text/javascript" src="doxygen-awesome-darkmode-toggle.js"></script>
<script type="text/javascript">
    DoxygenAwesomeDarkModeToggle.init()
</script>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname"><a href="index.html">yyjson</a><span id="projectnumber">&#160;0.12.0</span>
   </div>
   <div id="projectbrief">A high performance C JSON library.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.13.2 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() { codefold.init(0); });
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search',true);
  $(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function(){initNavTree('api.html',''); initResizable(true); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>

<div><div class="header">
  <div class="headertitle"><div class="title">API</div></div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>This document contains all the API usage and examples for the yyjson library.</p>
<h1><a class="anchor" id="api-design"></a>
API Design</h1>
<h2><a class="anchor" id="api-prefix"></a>
API prefix</h2>
<p>All public functions and structs are prefixed with <code>yyjson_</code>, and all constants are prefixed with <code>YYJSON_</code>.</p>
<h2><a class="anchor" id="api-for-immutablemutable-data"></a>
API for immutable/mutable data</h2>
<p>The library have 2 types of data structures: immutable and mutable:</p>
<table class="markdownTable">
<tr class="markdownTableHead">
<th class="markdownTableHeadNone"></th><th class="markdownTableHeadNone">Immutable   </th><th class="markdownTableHeadNone">Mutable    </th></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">Document   </td><td class="markdownTableBodyNone"><a class="el" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a>   </td><td class="markdownTableBodyNone"><a class="el" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a>    </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">Value   </td><td class="markdownTableBodyNone"><a class="el" href="yyjson_8h.html#structyyjson__val">yyjson_val</a>   </td><td class="markdownTableBodyNone"><a class="el" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a>   </td></tr>
</table>
<p>When reading a JSON, yyjson returns immutable documents and values.<br  />
 When building a JSON, yyjson creates mutable documents and values.<br  />
 The document holds the memory for all its JSON values and strings.<br  />
</p>
<p>For most immutable APIs, you can just add a <code>mut</code> after <code>yyjson_</code> to get the mutable version, for example: </p><div class="fragment"><div class="line"><span class="keywordtype">char</span> *<a class="code hl_function" href="yyjson_8h.html#ad231975496ac3788fe5d69804e295443">yyjson_write</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *doc, ...);</div>
<div class="line"><span class="keywordtype">char</span> *<a class="code hl_function" href="yyjson_8h.html#a881e2ee3f487385810829df8bc675f1f">yyjson_mut_write</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, ...);</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a52f3358d27af0b1f1aeb3fe4dc7da1c0">yyjson_is_str</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#ad9f16424bfef46cd479066905f653591">yyjson_mut_is_str</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *val);</div>
<div class="ttc" id="ayyjson_8h_html_a52f3358d27af0b1f1aeb3fe4dc7da1c0"><div class="ttname"><a href="yyjson_8h.html#a52f3358d27af0b1f1aeb3fe4dc7da1c0">yyjson_is_str</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_is_str(yyjson_val *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:5185</div></div>
<div class="ttc" id="ayyjson_8h_html_a881e2ee3f487385810829df8bc675f1f"><div class="ttname"><a href="yyjson_8h.html#a881e2ee3f487385810829df8bc675f1f">yyjson_mut_write</a></div><div class="ttdeci">yyjson_api_inline char * yyjson_mut_write(const yyjson_mut_doc *doc, yyjson_write_flag flg, size_t *len)</div><div class="ttdef"><b>Definition</b> yyjson.h:1461</div></div>
<div class="ttc" id="ayyjson_8h_html_ad231975496ac3788fe5d69804e295443"><div class="ttname"><a href="yyjson_8h.html#ad231975496ac3788fe5d69804e295443">yyjson_write</a></div><div class="ttdeci">yyjson_api_inline char * yyjson_write(const yyjson_doc *doc, yyjson_write_flag flg, size_t *len)</div><div class="ttdef"><b>Definition</b> yyjson.h:1356</div></div>
<div class="ttc" id="ayyjson_8h_html_ad9f16424bfef46cd479066905f653591"><div class="ttname"><a href="yyjson_8h.html#ad9f16424bfef46cd479066905f653591">yyjson_mut_is_str</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_is_str(yyjson_mut_val *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:5756</div></div>
<div class="ttc" id="ayyjson_8h_html_structyyjson__doc"><div class="ttname"><a href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a></div><div class="ttdef"><b>Definition</b> yyjson.h:4770</div></div>
<div class="ttc" id="ayyjson_8h_html_structyyjson__mut__doc"><div class="ttname"><a href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a></div><div class="ttdef"><b>Definition</b> yyjson.h:5638</div></div>
<div class="ttc" id="ayyjson_8h_html_structyyjson__mut__val"><div class="ttname"><a href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a></div><div class="ttdef"><b>Definition</b> yyjson.h:5590</div></div>
<div class="ttc" id="ayyjson_8h_html_structyyjson__val"><div class="ttname"><a href="yyjson_8h.html#structyyjson__val">yyjson_val</a></div><div class="ttdef"><b>Definition</b> yyjson.h:4765</div></div>
</div><!-- fragment --><p>The library also provides some functions to convert values between immutable and mutable:<br  />
</p>
<div class="fragment"><div class="line"><span class="comment">// doc -&gt; mut_doc</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *<a class="code hl_function" href="yyjson_8h.html#a083356ecb65e45453033285f3d836de9">yyjson_doc_mut_copy</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *doc, ...);</div>
<div class="line"><span class="comment">// val -&gt; mut_val</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a04ff184b833fe2d6932309821e2b2e5a">yyjson_val_mut_copy</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val, ...);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// mut_doc -&gt; doc</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *<a class="code hl_function" href="yyjson_8h.html#a797642b2f815a4f05db03ef87f08cc4f">yyjson_mut_doc_imut_copy</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, ...);</div>
<div class="line"><span class="comment">// mut_val -&gt; val</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *<a class="code hl_function" href="yyjson_8h.html#a7a142af553e7831989593aee44f74e26">yyjson_mut_val_imut_copy</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *val, ...);</div>
<div class="ttc" id="ayyjson_8h_html_a04ff184b833fe2d6932309821e2b2e5a"><div class="ttname"><a href="yyjson_8h.html#a04ff184b833fe2d6932309821e2b2e5a">yyjson_val_mut_copy</a></div><div class="ttdeci">yyjson_api yyjson_mut_val * yyjson_val_mut_copy(yyjson_mut_doc *doc, yyjson_val *val)</div></div>
<div class="ttc" id="ayyjson_8h_html_a083356ecb65e45453033285f3d836de9"><div class="ttname"><a href="yyjson_8h.html#a083356ecb65e45453033285f3d836de9">yyjson_doc_mut_copy</a></div><div class="ttdeci">yyjson_api yyjson_mut_doc * yyjson_doc_mut_copy(yyjson_doc *doc, const yyjson_alc *alc)</div></div>
<div class="ttc" id="ayyjson_8h_html_a797642b2f815a4f05db03ef87f08cc4f"><div class="ttname"><a href="yyjson_8h.html#a797642b2f815a4f05db03ef87f08cc4f">yyjson_mut_doc_imut_copy</a></div><div class="ttdeci">yyjson_api yyjson_doc * yyjson_mut_doc_imut_copy(yyjson_mut_doc *doc, const yyjson_alc *alc)</div></div>
<div class="ttc" id="ayyjson_8h_html_a7a142af553e7831989593aee44f74e26"><div class="ttname"><a href="yyjson_8h.html#a7a142af553e7831989593aee44f74e26">yyjson_mut_val_imut_copy</a></div><div class="ttdeci">yyjson_api yyjson_doc * yyjson_mut_val_imut_copy(yyjson_mut_val *val, const yyjson_alc *alc)</div></div>
</div><!-- fragment --><h2><a class="anchor" id="api-for-string"></a>
API for string</h2>
<p>The library supports strings with or without null-terminator ('\0').<br  />
 When you need to use a string without a null-terminator or when you explicitly know the length of the string, you can use the function that ends with <code>n</code>, for example: </p><div class="fragment"><div class="line"><span class="comment">// null-terminator is required</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a147b5b874e6b939731f1b6c15abcbbca">yyjson_equals_str</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val, <span class="keyword">const</span> <span class="keywordtype">char</span> *str);</div>
<div class="line"><span class="comment">// null-terminator is optional</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a1a7a91be15978b45345976c8432769aa">yyjson_equals_strn</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val, <span class="keyword">const</span> <span class="keywordtype">char</span> *str, <span class="keywordtype">size_t</span> len);</div>
<div class="ttc" id="ayyjson_8h_html_a147b5b874e6b939731f1b6c15abcbbca"><div class="ttname"><a href="yyjson_8h.html#a147b5b874e6b939731f1b6c15abcbbca">yyjson_equals_str</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_equals_str(yyjson_val *val, const char *str)</div><div class="ttdef"><b>Definition</b> yyjson.h:5272</div></div>
<div class="ttc" id="ayyjson_8h_html_a1a7a91be15978b45345976c8432769aa"><div class="ttname"><a href="yyjson_8h.html#a1a7a91be15978b45345976c8432769aa">yyjson_equals_strn</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_equals_strn(yyjson_val *val, const char *str, size_t len)</div><div class="ttdef"><b>Definition</b> yyjson.h:5280</div></div>
</div><!-- fragment --><p>When creating JSON, yyjson treats strings as constants for better performance. However, if your string will be modified, you should use a function with a <code>cpy</code> to copy the string to the document, for example: </p><div class="fragment"><div class="line"><span class="comment">// reference only, null-terminated is required</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#ae8d7e4c75adb1b9adb2246165491a4a3">yyjson_mut_str</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keyword">const</span> <span class="keywordtype">char</span> *str);</div>
<div class="line"><span class="comment">// reference only, null-terminator is optional</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a13c39f37c6936907c266ba9c076dd741">yyjson_mut_strn</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keyword">const</span> <span class="keywordtype">char</span> *str, <span class="keywordtype">size_t</span> len);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// copied, null-terminated is required</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a95300bcf1cdb52d296e39aa1a4650741">yyjson_mut_strcpy</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keyword">const</span> <span class="keywordtype">char</span> *str);</div>
<div class="line"><span class="comment">// copied, null-terminator is optional</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a1588bdc6f4125e5c6d1daf6b240f6ff8">yyjson_mut_strncpy</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keyword">const</span> <span class="keywordtype">char</span> *str, <span class="keywordtype">size_t</span> len);</div>
<div class="ttc" id="ayyjson_8h_html_a13c39f37c6936907c266ba9c076dd741"><div class="ttname"><a href="yyjson_8h.html#a13c39f37c6936907c266ba9c076dd741">yyjson_mut_strn</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_strn(yyjson_mut_doc *doc, const char *str, size_t len)</div><div class="ttdef"><b>Definition</b> yyjson.h:6060</div></div>
<div class="ttc" id="ayyjson_8h_html_a1588bdc6f4125e5c6d1daf6b240f6ff8"><div class="ttname"><a href="yyjson_8h.html#a1588bdc6f4125e5c6d1daf6b240f6ff8">yyjson_mut_strncpy</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_strncpy(yyjson_mut_doc *doc, const char *str, size_t len)</div><div class="ttdef"><b>Definition</b> yyjson.h:6079</div></div>
<div class="ttc" id="ayyjson_8h_html_a95300bcf1cdb52d296e39aa1a4650741"><div class="ttname"><a href="yyjson_8h.html#a95300bcf1cdb52d296e39aa1a4650741">yyjson_mut_strcpy</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_strcpy(yyjson_mut_doc *doc, const char *str)</div><div class="ttdef"><b>Definition</b> yyjson.h:6066</div></div>
<div class="ttc" id="ayyjson_8h_html_ae8d7e4c75adb1b9adb2246165491a4a3"><div class="ttname"><a href="yyjson_8h.html#ae8d7e4c75adb1b9adb2246165491a4a3">yyjson_mut_str</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_str(yyjson_mut_doc *doc, const char *str)</div><div class="ttdef"><b>Definition</b> yyjson.h:6055</div></div>
</div><!-- fragment --><hr  />
<h1><a class="anchor" id="reading-json"></a>
Reading JSON</h1>
<p>The library provides 5 functions for reading JSON.<br  />
 Each function accepts an input of UTF-8 data or a file,<br  />
 returns a document if it successful or <code>NULL</code> if it fails.</p>
<h2><a class="anchor" id="read-json-from-string"></a>
Read JSON from string</h2>
<p>The <code>dat</code> should be a UTF-8 string, null-terminator is not required.<br  />
 The <code>len</code> is the byte length of <code>dat</code>.<br  />
 The <code>flg</code> is reader flag, pass 0 if you don't need it, see <code>reader flag</code> for details.<br  />
 If input is invalid, <code>NULL</code> is returned.</p>
<div class="fragment"><div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *<a class="code hl_function" href="yyjson_8h.html#aeab3c2a1d86225e5b181fb1bba7587d4">yyjson_read</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *dat, </div>
<div class="line">                        <span class="keywordtype">size_t</span> len, </div>
<div class="line">                        <a class="code hl_typedef" href="yyjson_8h.html#a36af676813028c1360e8b343768f0e81">yyjson_read_flag</a> flg);</div>
<div class="ttc" id="ayyjson_8h_html_a36af676813028c1360e8b343768f0e81"><div class="ttname"><a href="yyjson_8h.html#a36af676813028c1360e8b343768f0e81">yyjson_read_flag</a></div><div class="ttdeci">uint32_t yyjson_read_flag</div><div class="ttdef"><b>Definition</b> yyjson.h:723</div></div>
<div class="ttc" id="ayyjson_8h_html_aeab3c2a1d86225e5b181fb1bba7587d4"><div class="ttname"><a href="yyjson_8h.html#aeab3c2a1d86225e5b181fb1bba7587d4">yyjson_read</a></div><div class="ttdeci">yyjson_api_inline yyjson_doc * yyjson_read(const char *dat, size_t len, yyjson_read_flag flg)</div><div class="ttdef"><b>Definition</b> yyjson.h:983</div></div>
</div><!-- fragment --><p> Sample code:</p>
<div class="fragment"><div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> *str = <span class="stringliteral">&quot;[1,2,3,4]&quot;</span>;</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *doc = <a class="code hl_function" href="yyjson_8h.html#aeab3c2a1d86225e5b181fb1bba7587d4">yyjson_read</a>(str, strlen(str), 0);</div>
<div class="line"><span class="keywordflow">if</span> (doc) {...}</div>
<div class="line"><a class="code hl_function" href="yyjson_8h.html#adad98bd766cf52d99f2c54dcb120786d">yyjson_doc_free</a>(doc);</div>
<div class="ttc" id="ayyjson_8h_html_adad98bd766cf52d99f2c54dcb120786d"><div class="ttname"><a href="yyjson_8h.html#adad98bd766cf52d99f2c54dcb120786d">yyjson_doc_free</a></div><div class="ttdeci">yyjson_api_inline void yyjson_doc_free(yyjson_doc *doc)</div><div class="ttdef"><b>Definition</b> yyjson.h:5130</div></div>
</div><!-- fragment --><h2><a class="anchor" id="read-json-from-file"></a>
Read JSON from file</h2>
<p>The <code>path</code> is JSON file path. This should be a null-terminated string using the system's native encoding.<br  />
 The <code>flg</code> is reader flag, pass 0 if you don't need it, see <code>reader flag</code> for details.<br  />
 The <code>alc</code> is memory allocator, pass NULL if you don't need it, see <code>memory allocator</code> for details.<br  />
 The <code>err</code> is a pointer to receive error message, pass NULL if you don't need it.<br  />
 If input is invalid, <code>NULL</code> is returned.</p>
<div class="fragment"><div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *<a class="code hl_function" href="yyjson_8h.html#a605ac08b083fb65331d7fa5eb5d32225">yyjson_read_file</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *path,</div>
<div class="line">                             <a class="code hl_typedef" href="yyjson_8h.html#a36af676813028c1360e8b343768f0e81">yyjson_read_flag</a> flg,</div>
<div class="line">                             <span class="keyword">const</span> <a class="code hl_struct" href="yyjson_8h.html#structyyjson__alc">yyjson_alc</a> *alc,</div>
<div class="line">                             <a class="code hl_struct" href="yyjson_8h.html#structyyjson__read__err">yyjson_read_err</a> *err);</div>
<div class="ttc" id="ayyjson_8h_html_a605ac08b083fb65331d7fa5eb5d32225"><div class="ttname"><a href="yyjson_8h.html#a605ac08b083fb65331d7fa5eb5d32225">yyjson_read_file</a></div><div class="ttdeci">yyjson_api yyjson_doc * yyjson_read_file(const char *path, yyjson_read_flag flg, const yyjson_alc *alc, yyjson_read_err *err)</div></div>
<div class="ttc" id="ayyjson_8h_html_structyyjson__alc"><div class="ttname"><a href="yyjson_8h.html#structyyjson__alc">yyjson_alc</a></div><div class="ttdef"><b>Definition</b> yyjson.h:586</div></div>
<div class="ttc" id="ayyjson_8h_html_structyyjson__read__err"><div class="ttname"><a href="yyjson_8h.html#structyyjson__read__err">yyjson_read_err</a></div><div class="ttdef"><b>Definition</b> yyjson.h:879</div></div>
</div><!-- fragment --><p>Sample code:</p>
<div class="fragment"><div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *doc = <a class="code hl_function" href="yyjson_8h.html#a605ac08b083fb65331d7fa5eb5d32225">yyjson_read_file</a>(<span class="stringliteral">&quot;/tmp/test.json&quot;</span>, 0, NULL, NULL);</div>
<div class="line"><span class="keywordflow">if</span> (doc) {...}</div>
<div class="line"><a class="code hl_function" href="yyjson_8h.html#adad98bd766cf52d99f2c54dcb120786d">yyjson_doc_free</a>(doc);</div>
</div><!-- fragment --><h2><a class="anchor" id="read-json-from-file-pointer"></a>
Read JSON from file pointer</h2>
<p>The <code>fp</code> is file pointer. The data will be read from the current position of the FILE to the end.<br  />
 The <code>flg</code> is reader flag, pass 0 if you don't need it, see <code>reader flag</code> for details.<br  />
 The <code>alc</code> is memory allocator, pass NULL if you don't need it, see <code>memory allocator</code> for details.<br  />
 The <code>err</code> is a pointer to receive error message, pass NULL if you don't need it.<br  />
 If input is invalid, <code>NULL</code> is returned.</p>
<div class="fragment"><div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *<a class="code hl_function" href="yyjson_8h.html#a7f8c3918f8ab161bf7e2e203ff0f291e">yyjson_read_fp</a>(FILE *fp,</div>
<div class="line">                           <a class="code hl_typedef" href="yyjson_8h.html#a36af676813028c1360e8b343768f0e81">yyjson_read_flag</a> flg,</div>
<div class="line">                           <span class="keyword">const</span> <a class="code hl_struct" href="yyjson_8h.html#structyyjson__alc">yyjson_alc</a> *alc,</div>
<div class="line">                           <a class="code hl_struct" href="yyjson_8h.html#structyyjson__read__err">yyjson_read_err</a> *err);</div>
<div class="ttc" id="ayyjson_8h_html_a7f8c3918f8ab161bf7e2e203ff0f291e"><div class="ttname"><a href="yyjson_8h.html#a7f8c3918f8ab161bf7e2e203ff0f291e">yyjson_read_fp</a></div><div class="ttdeci">yyjson_api yyjson_doc * yyjson_read_fp(FILE *fp, yyjson_read_flag flg, const yyjson_alc *alc, yyjson_read_err *err)</div></div>
</div><!-- fragment --><p>Sample code:</p>
<div class="fragment"><div class="line">FILE *fp = fdopen(fd, <span class="stringliteral">&quot;rb&quot;</span>); <span class="comment">// POSIX file descriptor (fd)</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *doc = <a class="code hl_function" href="yyjson_8h.html#a7f8c3918f8ab161bf7e2e203ff0f291e">yyjson_read_fp</a>(fp, 0, NULL, NULL);</div>
<div class="line"><span class="keywordflow">if</span> (fp) fclose(fp);</div>
<div class="line"><span class="keywordflow">if</span> (doc) {...}</div>
<div class="line"><a class="code hl_function" href="yyjson_8h.html#adad98bd766cf52d99f2c54dcb120786d">yyjson_doc_free</a>(doc);</div>
</div><!-- fragment --><h2><a class="anchor" id="read-json-with-options"></a>
Read JSON with options</h2>
<p>The <code>dat</code> should be a UTF-8 string, you can pass a const string if you don't use <code>YYJSON_READ_INSITU</code> flag.<br  />
 The <code>len</code> is the <code>dat</code>'s length in bytes.<br  />
 The <code>flg</code> is reader flag, pass 0 if you don't need it, see <code>reader flag</code> for details.<br  />
 The <code>alc</code> is memory allocator, pass NULL if you don't need it, see <code>memory allocator</code> for details.<br  />
 The <code>err</code> is a pointer to receive error message, pass NULL if you don't need it.<br  />
</p>
<div class="fragment"><div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *<a class="code hl_function" href="yyjson_8h.html#acf234d21f0cb4b7fc89381ef25e9f0a8">yyjson_read_opts</a>(<span class="keywordtype">char</span> *dat, </div>
<div class="line">                             <span class="keywordtype">size_t</span> len, </div>
<div class="line">                             <a class="code hl_typedef" href="yyjson_8h.html#a36af676813028c1360e8b343768f0e81">yyjson_read_flag</a> flg,</div>
<div class="line">                             <span class="keyword">const</span> <a class="code hl_struct" href="yyjson_8h.html#structyyjson__alc">yyjson_alc</a> *alc, </div>
<div class="line">                             <a class="code hl_struct" href="yyjson_8h.html#structyyjson__read__err">yyjson_read_err</a> *err);</div>
<div class="ttc" id="ayyjson_8h_html_acf234d21f0cb4b7fc89381ef25e9f0a8"><div class="ttname"><a href="yyjson_8h.html#acf234d21f0cb4b7fc89381ef25e9f0a8">yyjson_read_opts</a></div><div class="ttdeci">yyjson_api yyjson_doc * yyjson_read_opts(char *dat, size_t len, yyjson_read_flag flg, const yyjson_alc *alc, yyjson_read_err *err)</div></div>
</div><!-- fragment --><p>Sample code:</p>
<div class="fragment"><div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> *dat = your_file.bytes;</div>
<div class="line"><span class="keywordtype">size_t</span> len = your_file.size;</div>
<div class="line"> </div>
<div class="line"><a class="code hl_typedef" href="yyjson_8h.html#a36af676813028c1360e8b343768f0e81">yyjson_read_flag</a> flg = <a class="code hl_variable" href="yyjson_8h.html#aff1d62b68993630e74355e4611b77520">YYJSON_READ_ALLOW_COMMENTS</a> | <a class="code hl_variable" href="yyjson_8h.html#a4b5c0a7092625f0324bccec938f8862f">YYJSON_READ_ALLOW_INF_AND_NAN</a>;</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *doc = <a class="code hl_function" href="yyjson_8h.html#acf234d21f0cb4b7fc89381ef25e9f0a8">yyjson_read_opts</a>((<span class="keywordtype">char</span> *)dat, len, flg, NULL, NULL);</div>
<div class="line"> </div>
<div class="line"><span class="keywordflow">if</span> (doc) {...}</div>
<div class="line"> </div>
<div class="line"><a class="code hl_function" href="yyjson_8h.html#adad98bd766cf52d99f2c54dcb120786d">yyjson_doc_free</a>(doc);</div>
<div class="ttc" id="ayyjson_8h_html_a4b5c0a7092625f0324bccec938f8862f"><div class="ttname"><a href="yyjson_8h.html#a4b5c0a7092625f0324bccec938f8862f">YYJSON_READ_ALLOW_INF_AND_NAN</a></div><div class="ttdeci">static const yyjson_read_flag YYJSON_READ_ALLOW_INF_AND_NAN</div><div class="ttdef"><b>Definition</b> yyjson.h:757</div></div>
<div class="ttc" id="ayyjson_8h_html_aff1d62b68993630e74355e4611b77520"><div class="ttname"><a href="yyjson_8h.html#aff1d62b68993630e74355e4611b77520">YYJSON_READ_ALLOW_COMMENTS</a></div><div class="ttdeci">static const yyjson_read_flag YYJSON_READ_ALLOW_COMMENTS</div><div class="ttdef"><b>Definition</b> yyjson.h:753</div></div>
</div><!-- fragment --><h2><a class="anchor" id="read-json-incrementally"></a>
Read JSON incrementally</h2>
<p>Reading a very large JSON document can freeze the program for a short while. If this is not acceptable, incremental reading can be used.</p>
<p>Incremental reading is recommended only for large documents and only when the program needs to be responsive. Incremental reading is slightly slower than <code><a class="el" href="yyjson_8h.html#aeab3c2a1d86225e5b181fb1bba7587d4">yyjson_read()</a></code> and <code><a class="el" href="yyjson_8h.html#acf234d21f0cb4b7fc89381ef25e9f0a8">yyjson_read_opts()</a></code>.</p>
<p>Note: The incremental JSON reader only supports standard JSON. Flags for non-standard features (e.g. comments, trailing commas) are ignored.</p>
<p>To read a large JSON document incrementally:</p>
<ol type="1">
<li>Call <code><a class="el" href="yyjson_8h.html#a49c78bbfa5c961c1807d332f52d201f4">yyjson_incr_new()</a></code> to create the state for incremental reading.</li>
<li>Call <code><a class="el" href="yyjson_8h.html#adf5847c72fffb345de33667fd935097a">yyjson_incr_read()</a></code> repeatedly.</li>
<li>Call <code><a class="el" href="yyjson_8h.html#a333bd893cdd22a379e2476e90b5532f2">yyjson_incr_free()</a></code> to free the state.</li>
</ol>
<h3><a class="anchor" id="create-the-state-for-incremental-reading"></a>
Create the state for incremental reading</h3>
<p>The <code>buf</code> should be a UTF-8 string, null-terminator is not required. You can pass a const string if you don't use the <code>YYJSON_READ_INSITU</code> flag.<br  />
 The <code>buf_len</code> is the length of <code>buf</code> in bytes. The <code>flg</code> is reader flag. Pass 0 if you don't need it. See reader flag for details. The <code>alc</code> is memory allocator, pass NULL if you don't need it. See <code>memory allocator</code> for details.<br  />
</p>
<p>The function returns a new state, or NULL if <code>flg</code> is invalid or if a memory allocation error occurs.</p>
<div class="fragment"><div class="line"><a class="code hl_typedef" href="yyjson_8h.html#a1961d8efe52ccb4f0de1c84f68f22e94">yyjson_incr_state</a> *<a class="code hl_function" href="yyjson_8h.html#a49c78bbfa5c961c1807d332f52d201f4">yyjson_incr_new</a>(<span class="keywordtype">char</span> *buf, <span class="keywordtype">size_t</span> buf_len, <a class="code hl_typedef" href="yyjson_8h.html#a36af676813028c1360e8b343768f0e81">yyjson_read_flag</a> flg, <span class="keyword">const</span> <a class="code hl_struct" href="yyjson_8h.html#structyyjson__alc">yyjson_alc</a> *alc);</div>
<div class="ttc" id="ayyjson_8h_html_a1961d8efe52ccb4f0de1c84f68f22e94"><div class="ttname"><a href="yyjson_8h.html#a1961d8efe52ccb4f0de1c84f68f22e94">yyjson_incr_state</a></div><div class="ttdeci">struct yyjson_incr_state yyjson_incr_state</div><div class="ttdef"><b>Definition</b> yyjson.h:996</div></div>
<div class="ttc" id="ayyjson_8h_html_a49c78bbfa5c961c1807d332f52d201f4"><div class="ttname"><a href="yyjson_8h.html#a49c78bbfa5c961c1807d332f52d201f4">yyjson_incr_new</a></div><div class="ttdeci">yyjson_api yyjson_incr_state * yyjson_incr_new(char *buf, size_t buf_len, yyjson_read_flag flg, const yyjson_alc *alc)</div></div>
</div><!-- fragment --><h3><a class="anchor" id="perform-incremental-read"></a>
Perform incremental read</h3>
<p>Performs incremental read of up to <code>len</code> bytes.</p>
<p>The <code>state</code> for incremental reading is created using <code><a class="el" href="yyjson_8h.html#a49c78bbfa5c961c1807d332f52d201f4">yyjson_incr_new()</a></code>.<br  />
 The <code>len</code> is the maximum number of bytes to read, counting from the start of the JSON data.<br  />
 The <code>err</code> is a pointer to receive the error information. Required.<br  />
</p>
<p>The function returns a document object when the reading is complete and NULL otherwise. If <code>err-&gt;code</code> is set to <code>YYJSON_READ_ERROR_MORE</code>, it indicates that parsing is not yet complete. Then, increase <code>len</code> by some kilobytes and call this function again. Continue increasing <code>len</code> until <code>len == buf_len</code> (the total length of the input buffer) or until an error other than <code>YYJSON_READ_ERROR_MORE</code> is returned.</p>
<p>Note: Parsing in very small increments is not efficient. An increment of several kilobytes or megabytes is recommended.</p>
<div class="fragment"><div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *<a class="code hl_function" href="yyjson_8h.html#adf5847c72fffb345de33667fd935097a">yyjson_incr_read</a>(<a class="code hl_typedef" href="yyjson_8h.html#a1961d8efe52ccb4f0de1c84f68f22e94">yyjson_incr_state</a> *state, <span class="keywordtype">size_t</span> len, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__read__err">yyjson_read_err</a> *err);</div>
<div class="ttc" id="ayyjson_8h_html_adf5847c72fffb345de33667fd935097a"><div class="ttname"><a href="yyjson_8h.html#adf5847c72fffb345de33667fd935097a">yyjson_incr_read</a></div><div class="ttdeci">yyjson_api yyjson_doc * yyjson_incr_read(yyjson_incr_state *state, size_t len, yyjson_read_err *err)</div></div>
</div><!-- fragment --><h3><a class="anchor" id="free-the-state-used-for-incremental-reading"></a>
Free the state used for incremental reading</h3>
<p>Free the <code>state</code> created by <code><a class="el" href="yyjson_8h.html#a49c78bbfa5c961c1807d332f52d201f4">yyjson_incr_new()</a></code>.</p>
<div class="fragment"><div class="line"><span class="keywordtype">void</span> <a class="code hl_function" href="yyjson_8h.html#a333bd893cdd22a379e2476e90b5532f2">yyjson_incr_free</a>(<a class="code hl_typedef" href="yyjson_8h.html#a1961d8efe52ccb4f0de1c84f68f22e94">yyjson_incr_state</a> *state);</div>
<div class="ttc" id="ayyjson_8h_html_a333bd893cdd22a379e2476e90b5532f2"><div class="ttname"><a href="yyjson_8h.html#a333bd893cdd22a379e2476e90b5532f2">yyjson_incr_free</a></div><div class="ttdeci">yyjson_api void yyjson_incr_free(yyjson_incr_state *state)</div></div>
</div><!-- fragment --><h3><a class="anchor" id="sample-code-1"></a>
Sample code</h3>
<div class="fragment"><div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> *dat = your_file.bytes;</div>
<div class="line"><span class="keywordtype">size_t</span> len = your_file.size;</div>
<div class="line"> </div>
<div class="line"><a class="code hl_typedef" href="yyjson_8h.html#a36af676813028c1360e8b343768f0e81">yyjson_read_flag</a> flg = <a class="code hl_variable" href="yyjson_8h.html#a8940a4ae4ba3467bb7bc6c5ee3deb2ea">YYJSON_READ_NOFLAG</a>;</div>
<div class="line"><a class="code hl_typedef" href="yyjson_8h.html#a1961d8efe52ccb4f0de1c84f68f22e94">yyjson_incr_state</a> *state = <a class="code hl_function" href="yyjson_8h.html#a49c78bbfa5c961c1807d332f52d201f4">yyjson_incr_new</a>(dat, len, flg, NULL);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *doc;</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__read__err">yyjson_read_err</a> err;</div>
<div class="line"><span class="keywordtype">size_t</span> read_so_far = 0;</div>
<div class="line"><span class="keywordflow">do</span> {</div>
<div class="line">    read_so_far += 100000;</div>
<div class="line">    <span class="keywordflow">if</span> (read_so_far &gt; len)</div>
<div class="line">        read_so_far = len;</div>
<div class="line">    doc = <a class="code hl_function" href="yyjson_8h.html#adf5847c72fffb345de33667fd935097a">yyjson_incr_read</a>(state, read_so_far, &amp;err);</div>
<div class="line">    <span class="keywordflow">if</span> (err.<a class="code hl_variable" href="yyjson_8h.html#a550600110929a7030f464a460b5b62cb">code</a> != <a class="code hl_variable" href="yyjson_8h.html#a48706a3eb7761926a6c0ec3239dda76c">YYJSON_READ_ERROR_MORE</a>)</div>
<div class="line">        <span class="keywordflow">break</span>;</div>
<div class="line">} <span class="keywordflow">while</span> (read_so_far &lt; len);</div>
<div class="line"><a class="code hl_function" href="yyjson_8h.html#a333bd893cdd22a379e2476e90b5532f2">yyjson_incr_free</a>(state);</div>
<div class="line"> </div>
<div class="line"><span class="keywordflow">if</span> (doc != NULL) { ... }</div>
<div class="line"> </div>
<div class="line"><a class="code hl_function" href="yyjson_8h.html#adad98bd766cf52d99f2c54dcb120786d">yyjson_doc_free</a>(doc);</div>
<div class="ttc" id="ayyjson_8h_html_a48706a3eb7761926a6c0ec3239dda76c"><div class="ttname"><a href="yyjson_8h.html#a48706a3eb7761926a6c0ec3239dda76c">YYJSON_READ_ERROR_MORE</a></div><div class="ttdeci">static const yyjson_read_code YYJSON_READ_ERROR_MORE</div><div class="ttdef"><b>Definition</b> yyjson.h:876</div></div>
<div class="ttc" id="ayyjson_8h_html_a550600110929a7030f464a460b5b62cb"><div class="ttname"><a href="yyjson_8h.html#a550600110929a7030f464a460b5b62cb">yyjson_read_err::code</a></div><div class="ttdeci">yyjson_read_code code</div><div class="ttdef"><b>Definition</b> yyjson.h:881</div></div>
<div class="ttc" id="ayyjson_8h_html_a8940a4ae4ba3467bb7bc6c5ee3deb2ea"><div class="ttname"><a href="yyjson_8h.html#a8940a4ae4ba3467bb7bc6c5ee3deb2ea">YYJSON_READ_NOFLAG</a></div><div class="ttdeci">static const yyjson_read_flag YYJSON_READ_NOFLAG</div><div class="ttdef"><b>Definition</b> yyjson.h:733</div></div>
</div><!-- fragment --><h2><a class="anchor" id="reader-error-handling"></a>
Reader error handling</h2>
<p>When reading JSON fails and you need error information, you can pass a <code><a class="el" href="yyjson_8h.html#structyyjson__read__err">yyjson_read_err</a></code> pointer to the <code>yyjson_read_xxx()</code> functions to receive the error details.</p>
<p>Sample code: </p><div class="fragment"><div class="line"><span class="keywordtype">char</span> *dat = ...;</div>
<div class="line"><span class="keywordtype">size_t</span> dat_len = ...;</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__read__err">yyjson_read_err</a> err;</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *doc = <a class="code hl_function" href="yyjson_8h.html#acf234d21f0cb4b7fc89381ef25e9f0a8">yyjson_read_opts</a>(dat, dat_len, 0, NULL, &amp;err);</div>
<div class="line"> </div>
<div class="line"><span class="keywordflow">if</span> (!doc) {</div>
<div class="line">    printf(<span class="stringliteral">&quot;read error: %s, code: %u at byte position: %lu\n&quot;</span>, </div>
<div class="line">            err.<a class="code hl_variable" href="yyjson_8h.html#a9044823fa7fb431019662e589d45707c">msg</a>, err.<a class="code hl_variable" href="yyjson_8h.html#a550600110929a7030f464a460b5b62cb">code</a>, err.<a class="code hl_variable" href="yyjson_8h.html#a87eb200779eff088b93ea0a67ab3e300">pos</a>);</div>
<div class="line">    <span class="comment">// printed:</span></div>
<div class="line">    <span class="comment">// read error: trailing comma is not allowed, code: 7, at byte position: 40</span></div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><a class="code hl_function" href="yyjson_8h.html#adad98bd766cf52d99f2c54dcb120786d">yyjson_doc_free</a>(doc);</div>
<div class="ttc" id="ayyjson_8h_html_a87eb200779eff088b93ea0a67ab3e300"><div class="ttname"><a href="yyjson_8h.html#a87eb200779eff088b93ea0a67ab3e300">yyjson_read_err::pos</a></div><div class="ttdeci">size_t pos</div><div class="ttdef"><b>Definition</b> yyjson.h:885</div></div>
<div class="ttc" id="ayyjson_8h_html_a9044823fa7fb431019662e589d45707c"><div class="ttname"><a href="yyjson_8h.html#a9044823fa7fb431019662e589d45707c">yyjson_read_err::msg</a></div><div class="ttdeci">const char * msg</div><div class="ttdef"><b>Definition</b> yyjson.h:883</div></div>
</div><!-- fragment --><p>The pos in the error information indicates the byte position where the error occurred. If you need the line and column number of the error, you can use the <code><a class="el" href="yyjson_8h.html#ac742b11ff26fb9af6362ffd2f3f21061">yyjson_locate_pos()</a></code> function. Note that the <code>line</code> and <code>column</code> start from 1, while <code>character</code> starts from 0. All values are calculated based on Unicode characters to ensure compatibility with various text editors.</p>
<p>Sample code: </p><div class="fragment"><div class="line"><span class="keywordtype">char</span> *dat = ...;</div>
<div class="line"><span class="keywordtype">size_t</span> dat_len = ...;</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__read__err">yyjson_read_err</a> err = ...;</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">size_t</span> line, col, chr;</div>
<div class="line"><span class="keywordflow">if</span> (<a class="code hl_function" href="yyjson_8h.html#ac742b11ff26fb9af6362ffd2f3f21061">yyjson_locate_pos</a>(dat, dat_len, err.<a class="code hl_variable" href="yyjson_8h.html#a87eb200779eff088b93ea0a67ab3e300">pos</a>, &amp;line, &amp;col, &amp;chr)) {</div>
<div class="line">    printf(<span class="stringliteral">&quot;error at line: %lu, column: %lu, character index: %lu\n&quot;</span>,</div>
<div class="line">           line, col, chr);</div>
<div class="line">    <span class="comment">// printed:</span></div>
<div class="line">    <span class="comment">// error at line: 3, column: 5, character index: 32</span></div>
<div class="line">}</div>
<div class="ttc" id="ayyjson_8h_html_ac742b11ff26fb9af6362ffd2f3f21061"><div class="ttname"><a href="yyjson_8h.html#ac742b11ff26fb9af6362ffd2f3f21061">yyjson_locate_pos</a></div><div class="ttdeci">yyjson_api bool yyjson_locate_pos(const char *str, size_t len, size_t pos, size_t *line, size_t *col, size_t *chr)</div></div>
</div><!-- fragment --><h2><a class="anchor" id="reader-flag"></a>
Reader flag</h2>
<p>The library provides a set of flags for JSON reader.<br  />
</p>
<p>You can use a single flag, or combine multiple flags with bitwise <code>|</code> operator.<br  />
</p>
<p>Non-standard flags (such as <code>YYJSON_READ_JSON5</code>) have no performance impact when reading standard JSON input.</p>
<h3><a class="anchor" id="yyjson_read_noflag--0"></a>
<b>YYJSON_READ_NOFLAG = 0</b></h3>
<p>This is the default flag for JSON reader (RFC-8259 or ECMA-404 compliant):</p>
<ul>
<li>Read positive integer as <code>uint64_t</code>.</li>
<li>Read negative integer as <code>int64_t</code>.</li>
<li>Read floating-point number as <code>double</code> with correct rounding.</li>
<li>Read integer which cannot fit in <code>uint64_t</code> or <code>int64_t</code> as <code>double</code>.</li>
<li>Report error if double number is infinity.</li>
<li>Report error if string contains invalid UTF-8 character or BOM.</li>
<li>Report error on trailing commas, comments, <code>Inf</code> and <code>NaN</code> literals.</li>
</ul>
<h3><a class="anchor" id="yyjson_read_insitu"></a>
<b>YYJSON_READ_INSITU</b></h3>
<p>Read the input data in-situ.<br  />
</p>
<p>This option allows the reader to modify and use the input data to store string values, which can slightly improve reading speed. However, the caller must ensure that the input data is held until the document is freed. The input data must be padded with at least <code>YYJSON_PADDING_SIZE</code> bytes. For example: <code>[1,2]</code> should be <code>[1,2]\0\0\0\0</code>, input length should be 5.</p>
<p>Sample code:</p>
<div class="fragment"><div class="line"><span class="keywordtype">size_t</span> dat_len = ...;</div>
<div class="line"><span class="keywordtype">char</span> *buf = malloc(dat_len + <a class="code hl_define" href="yyjson_8h.html#abbe8e69f634b1a5a78c1dae08b88e0ef">YYJSON_PADDING_SIZE</a>); <span class="comment">// create a buffer larger than (len + 4)</span></div>
<div class="line">read_from_socket(buf, ...);</div>
<div class="line">memset(buf + file_size, 0, <a class="code hl_define" href="yyjson_8h.html#abbe8e69f634b1a5a78c1dae08b88e0ef">YYJSON_PADDING_SIZE</a>); <span class="comment">// set 4-byte padding after data</span></div>
<div class="line"> </div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *doc = <a class="code hl_function" href="yyjson_8h.html#acf234d21f0cb4b7fc89381ef25e9f0a8">yyjson_read_opts</a>(buf, dat_len, <a class="code hl_variable" href="yyjson_8h.html#aa476cdc60442393b93dd0474ed4f08bc">YYJSON_READ_INSITU</a>, NULL, NULL);</div>
<div class="line"><span class="keywordflow">if</span> (doc) {...}</div>
<div class="line"><a class="code hl_function" href="yyjson_8h.html#adad98bd766cf52d99f2c54dcb120786d">yyjson_doc_free</a>(doc);</div>
<div class="line">free(buf); <span class="comment">// the input dat should free after document.</span></div>
<div class="ttc" id="ayyjson_8h_html_aa476cdc60442393b93dd0474ed4f08bc"><div class="ttname"><a href="yyjson_8h.html#aa476cdc60442393b93dd0474ed4f08bc">YYJSON_READ_INSITU</a></div><div class="ttdeci">static const yyjson_read_flag YYJSON_READ_INSITU</div><div class="ttdef"><b>Definition</b> yyjson.h:741</div></div>
<div class="ttc" id="ayyjson_8h_html_abbe8e69f634b1a5a78c1dae08b88e0ef"><div class="ttname"><a href="yyjson_8h.html#abbe8e69f634b1a5a78c1dae08b88e0ef">YYJSON_PADDING_SIZE</a></div><div class="ttdeci">#define YYJSON_PADDING_SIZE</div><div class="ttdef"><b>Definition</b> yyjson.h:572</div></div>
</div><!-- fragment --><h3><a class="anchor" id="yyjson_read_stop_when_done"></a>
<b>YYJSON_READ_STOP_WHEN_DONE</b></h3>
<p>Stop parsing when reaching the end of a JSON document instead of issues an error if there's additional content after it.<br  />
</p>
<p>This option is useful for parsing small pieces of JSON within larger data, such as <a href="https://en.wikipedia.org/wiki/JSON_streaming">NDJSON</a>.<br  />
</p>
<p>Sample code:</p>
<div class="fragment"><div class="line"><span class="comment">// Single file with multiple JSON, such as:</span></div>
<div class="line"><span class="comment">// [1,2,3] [4,5,6] {&quot;a&quot;:&quot;b&quot;}</span></div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">size_t</span> file_size = ...;</div>
<div class="line"><span class="keywordtype">char</span> *dat = malloc(file_size + 4);</div>
<div class="line">your_read_file(dat, file);</div>
<div class="line">memset(dat + file_size, 0, 4); <span class="comment">// add padding</span></div>
<div class="line">    </div>
<div class="line"><span class="keywordtype">char</span> *hdr = dat;</div>
<div class="line"><span class="keywordtype">char</span> *end = dat + file_size;</div>
<div class="line"><a class="code hl_typedef" href="yyjson_8h.html#a36af676813028c1360e8b343768f0e81">yyjson_read_flag</a> flg = <a class="code hl_variable" href="yyjson_8h.html#aa476cdc60442393b93dd0474ed4f08bc">YYJSON_READ_INSITU</a> | <a class="code hl_variable" href="yyjson_8h.html#ad2fb99734b237a7af74924443fe5260e">YYJSON_READ_STOP_WHEN_DONE</a>;</div>
<div class="line"> </div>
<div class="line"><span class="keywordflow">while</span> (<span class="keyword">true</span>) {</div>
<div class="line">    <a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *doc = <a class="code hl_function" href="yyjson_8h.html#acf234d21f0cb4b7fc89381ef25e9f0a8">yyjson_read_opts</a>(hdr, end - hdr, flg, NULL, NULL);</div>
<div class="line">    <span class="keywordflow">if</span> (!doc) <span class="keywordflow">break</span>;</div>
<div class="line">    your_doc_process(doc);</div>
<div class="line">    hdr += <a class="code hl_function" href="yyjson_8h.html#a33580e2537c25685fd1209951dcbc967">yyjson_doc_get_read_size</a>(doc); <span class="comment">// move to next position</span></div>
<div class="line">    <a class="code hl_function" href="yyjson_8h.html#adad98bd766cf52d99f2c54dcb120786d">yyjson_doc_free</a>(doc);</div>
<div class="line">}</div>
<div class="line">free(dat);</div>
<div class="ttc" id="ayyjson_8h_html_a33580e2537c25685fd1209951dcbc967"><div class="ttname"><a href="yyjson_8h.html#a33580e2537c25685fd1209951dcbc967">yyjson_doc_get_read_size</a></div><div class="ttdeci">yyjson_api_inline size_t yyjson_doc_get_read_size(yyjson_doc *doc)</div><div class="ttdef"><b>Definition</b> yyjson.h:5122</div></div>
<div class="ttc" id="ayyjson_8h_html_ad2fb99734b237a7af74924443fe5260e"><div class="ttname"><a href="yyjson_8h.html#ad2fb99734b237a7af74924443fe5260e">YYJSON_READ_STOP_WHEN_DONE</a></div><div class="ttdeci">static const yyjson_read_flag YYJSON_READ_STOP_WHEN_DONE</div><div class="ttdef"><b>Definition</b> yyjson.h:746</div></div>
</div><!-- fragment --><h3><a class="anchor" id="yyjson_read_allow_trailing_commas"></a>
<b>YYJSON_READ_ALLOW_TRAILING_COMMAS</b></h3>
<p>Allow a single trailing comma at the end of an object or array (non-standard), for example:</p>
<div class="fragment"><div class="line">{</div>
<div class="line">    &quot;a&quot;: 1,</div>
<div class="line">    &quot;b&quot;: 2,</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line">[</div>
<div class="line">    &quot;a&quot;,</div>
<div class="line">    &quot;b&quot;,</div>
<div class="line">]</div>
</div><!-- fragment --><h3><a class="anchor" id="yyjson_read_allow_comments"></a>
<b>YYJSON_READ_ALLOW_COMMENTS</b></h3>
<p>Allow C-style single-line and multi-line comments (non-standard), for example:</p>
<div class="fragment"><div class="line">{</div>
<div class="line">    &quot;name&quot;: &quot;Harry&quot;, // single-line comment</div>
<div class="line">    &quot;id&quot;: /* multi-line comment */ 123</div>
<div class="line">}</div>
</div><!-- fragment --><h3><a class="anchor" id="yyjson_read_allow_inf_and_nan"></a>
<b>YYJSON_READ_ALLOW_INF_AND_NAN</b></h3>
<p>Allow nan/inf number or case-insensitive literal (non-standard), for example:</p>
<div class="fragment"><div class="line">{</div>
<div class="line">    &quot;large&quot;: 123e999,</div>
<div class="line">    &quot;nan1&quot;: NaN,</div>
<div class="line">    &quot;nan2&quot;: nan,</div>
<div class="line">    &quot;inf1&quot;: Inf,</div>
<div class="line">    &quot;inf2&quot;: -Infinity</div>
<div class="line">}</div>
</div><!-- fragment --><h3><a class="anchor" id="yyjson_read_number_as_raw"></a>
<b>YYJSON_READ_NUMBER_AS_RAW</b></h3>
<p>Read all numbers as raw strings without parsing.</p>
<p>This flag is useful if you want to handle number parsing yourself. You can use the following functions to extract raw strings: </p><div class="fragment"><div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a286c610e7e27b8b4667a93eba2e2fa28">yyjson_is_raw</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val);</div>
<div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code hl_function" href="yyjson_8h.html#a5e90e838f969425f75372d4b4246d145">yyjson_get_raw</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val);</div>
<div class="line"><span class="keywordtype">size_t</span> <a class="code hl_function" href="yyjson_8h.html#ae4b5e4edc9713d9f48e2a6750ad5ebff">yyjson_get_len</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val)</div>
<div class="ttc" id="ayyjson_8h_html_a286c610e7e27b8b4667a93eba2e2fa28"><div class="ttname"><a href="yyjson_8h.html#a286c610e7e27b8b4667a93eba2e2fa28">yyjson_is_raw</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_is_raw(yyjson_val *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:5145</div></div>
<div class="ttc" id="ayyjson_8h_html_a5e90e838f969425f75372d4b4246d145"><div class="ttname"><a href="yyjson_8h.html#a5e90e838f969425f75372d4b4246d145">yyjson_get_raw</a></div><div class="ttdeci">yyjson_api_inline const char * yyjson_get_raw(yyjson_val *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:5236</div></div>
<div class="ttc" id="ayyjson_8h_html_ae4b5e4edc9713d9f48e2a6750ad5ebff"><div class="ttname"><a href="yyjson_8h.html#ae4b5e4edc9713d9f48e2a6750ad5ebff">yyjson_get_len</a></div><div class="ttdeci">yyjson_api_inline size_t yyjson_get_len(yyjson_val *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:5268</div></div>
</div><!-- fragment --><h3><a class="anchor" id="yyjson_read_bignum_as_raw"></a>
<b>YYJSON_READ_BIGNUM_AS_RAW</b></h3>
<p>Read big numbers as raw strings.</p>
<p>This flag is useful if you want to parse these big numbers yourself. These big numbers include integers that cannot be represented by <code>int64_t</code> and <code>uint64_t</code>, and floating-point numbers that cannot be represented by finite <code>double</code>.</p>
<p>Note that this flag will be overridden by <code>YYJSON_READ_NUMBER_AS_RAW</code> flag.</p>
<h3><a class="anchor" id="yyjson_read_allow_invalid_unicode"></a>
<b>YYJSON_READ_ALLOW_INVALID_UNICODE</b></h3>
<p>Allow reading invalid unicode when parsing string values (non-standard), for example: </p><div class="fragment"><div class="line">&quot;\x80xyz&quot;</div>
<div class="line">&quot;\xF0\x81\x81\x81&quot;</div>
</div><!-- fragment --><p> This flag permits invalid characters to appear in the string values, but it still reports errors for invalid escape sequences. It does not impact the performance of correctly encoded strings.</p>
<p><em><b>Warning</b></em>: when using this option, be aware that strings within JSON values may contain incorrect encoding, so you need to handle these strings carefully to avoid security risks.</p>
<h3><a class="anchor" id="yyjson_read_allow_bom"></a>
<b>YYJSON_READ_ALLOW_BOM</b></h3>
<p>Allow UTF-8 BOM and skip it before parsing if any (non-standard).</p>
<h3><a class="anchor" id="yyjson_read_allow_ext_number"></a>
<b>YYJSON_READ_ALLOW_EXT_NUMBER</b></h3>
<p>Allow extended number formats (non-standard):</p><ul>
<li>Hexadecimal numbers, such as <code>0x7B</code>.</li>
<li>Numbers with leading or trailing decimal point, such as <code>.123</code>, <code>123.</code>.</li>
<li>Numbers with a leading plus sign, such as <code>+123</code>.</li>
</ul>
<h3><a class="anchor" id="yyjson_read_allow_ext_escape"></a>
<b>YYJSON_READ_ALLOW_EXT_ESCAPE</b></h3>
<p>Allow extended escape sequences in strings (non-standard):</p><ul>
<li>Additional escapes: <code>\a</code>, <code>\e</code>, <code>\v</code>, <code>\'</code>, <code>\?</code>, <code>\0</code>.</li>
<li>Hex escapes: <code>\xNN</code>, such as <code>\x7B</code>.</li>
<li>Line continuation: backslash followed by line terminator sequences.</li>
<li>Unknown escape: if backslash is followed by an unsupported character, the backslash will be removed and the character will be kept as-is. However, <code>\1</code>-<code>\9</code> will still trigger an error.</li>
</ul>
<h3><a class="anchor" id="yyjson_read_allow_ext_whitespace"></a>
<b>YYJSON_READ_ALLOW_EXT_WHITESPACE</b></h3>
<p>Allow extended whitespace characters (non-standard):</p><ul>
<li>Vertical tab <code>\v</code> and form feed <code>\f</code>.</li>
<li>Line separator <code>\u2028</code> and paragraph separator <code>\u2029</code>.</li>
<li>Non-breaking space <code>\xA0</code>.</li>
<li>Byte order mark: <code>\uFEFF</code>.</li>
<li>Other Unicode characters in the Zs (Separator, space) category.</li>
</ul>
<h3><a class="anchor" id="yyjson_read_allow_single_quoted_str"></a>
<b>YYJSON_READ_ALLOW_SINGLE_QUOTED_STR</b></h3>
<p>Allow strings enclosed in single quotes (non-standard), such as <code>'ab'</code>.</p>
<h3><a class="anchor" id="yyjson_read_allow_unquoted_key"></a>
<b>YYJSON_READ_ALLOW_UNQUOTED_KEY</b></h3>
<p>Allow object keys without quotes (non-standard), such as <code>{a:1,b:2}</code>. This extends the ECMAScript IdentifierName rule by allowing any non-whitespace character with code point above <code>U+007F</code>.</p>
<h3><a class="anchor" id="yyjson_read_json5"></a>
<b>YYJSON_READ_JSON5</b></h3>
<p>Allow JSON5 format, see: <a href="https://json5.org">https://json5.org</a>.</p>
<p>This flag supports all JSON5 features with some additional extensions:</p><ul>
<li>Accepts more escape sequences than JSON5 (e.g. <code>\a</code>, <code>\e</code>).</li>
<li>Unquoted keys are and not limited to ECMAScript IdentifierName.</li>
<li>Allow case-insensitive <code>NaN</code>, <code>Inf</code> and <code>Infinity</code> literals.</li>
</ul>
<p>For example: </p><div class="fragment"><div class="line">{</div>
<div class="line">    /* JSON5 example */</div>
<div class="line">    id: 123,</div>
<div class="line">    name: &#39;Harry&#39;,</div>
<div class="line">    color: 0x66CCFF,</div>
<div class="line">    min: .001,</div>
<div class="line">    max: Inf,</div>
<div class="line">    data: &#39;\x00\xAA\xFF&#39;,</div>
<div class="line">}</div>
</div><!-- fragment --><hr  />
 <h1><a class="anchor" id="writing-json"></a>
Writing JSON</h1>
<p>The library provides 4 sets of functions for writing JSON.<br  />
 Each function accepts an input of JSON document or root value, and returns a UTF-8 string or file.</p>
<h2><a class="anchor" id="write-json-to-string"></a>
Write JSON to string</h2>
<p>The <code>doc/val</code> is JSON document or root value, if you pass NULL, you will get NULL result.<br  />
 The <code>flg</code> is writer flag, pass 0 if you don't need it, see <code>writer flag</code> for details.<br  />
 The <code>len</code> is a pointer to receive output length (not including the null-terminator), pass NULL if you don't need it.<br  />
 This function returns a new JSON string, or NULL if error occurs.<br  />
 The string is encoded as UTF-8 with a null-terminator. <br  />
 You should use free() or alc-&gt;free() to release it when it's no longer needed.</p>
<div class="fragment"><div class="line"><span class="comment">// doc -&gt; str</span></div>
<div class="line"><span class="keywordtype">char</span> *<a class="code hl_function" href="yyjson_8h.html#ad231975496ac3788fe5d69804e295443">yyjson_write</a>(<span class="keyword">const</span> <a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *doc, <a class="code hl_typedef" href="yyjson_8h.html#afb7989387fc481f678e13325c18e6338">yyjson_write_flag</a> flg, <span class="keywordtype">size_t</span> *len);</div>
<div class="line"><span class="comment">// mut_doc -&gt; str</span></div>
<div class="line"><span class="keywordtype">char</span> *<a class="code hl_function" href="yyjson_8h.html#a881e2ee3f487385810829df8bc675f1f">yyjson_mut_write</a>(<span class="keyword">const</span> <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_typedef" href="yyjson_8h.html#afb7989387fc481f678e13325c18e6338">yyjson_write_flag</a> flg, <span class="keywordtype">size_t</span> *len);</div>
<div class="line"><span class="comment">// val -&gt; str</span></div>
<div class="line"><span class="keywordtype">char</span> *<a class="code hl_function" href="yyjson_8h.html#a00409eb59aee687f7778d00510b59d38">yyjson_val_write</a>(<span class="keyword">const</span> <a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val, <a class="code hl_typedef" href="yyjson_8h.html#afb7989387fc481f678e13325c18e6338">yyjson_write_flag</a> flg, <span class="keywordtype">size_t</span> *len);</div>
<div class="line"><span class="comment">// mut_val -&gt; str</span></div>
<div class="line"><span class="keywordtype">char</span> *<a class="code hl_function" href="yyjson_8h.html#a700da5ce5bf8bb9d3739cc73a0f51cdf">yyjson_mut_val_write</a>(<span class="keyword">const</span> <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *val, <a class="code hl_typedef" href="yyjson_8h.html#afb7989387fc481f678e13325c18e6338">yyjson_write_flag</a> flg, <span class="keywordtype">size_t</span> *len);</div>
<div class="ttc" id="ayyjson_8h_html_a00409eb59aee687f7778d00510b59d38"><div class="ttname"><a href="yyjson_8h.html#a00409eb59aee687f7778d00510b59d38">yyjson_val_write</a></div><div class="ttdeci">yyjson_api_inline char * yyjson_val_write(const yyjson_val *val, yyjson_write_flag flg, size_t *len)</div><div class="ttdef"><b>Definition</b> yyjson.h:1567</div></div>
<div class="ttc" id="ayyjson_8h_html_a700da5ce5bf8bb9d3739cc73a0f51cdf"><div class="ttname"><a href="yyjson_8h.html#a700da5ce5bf8bb9d3739cc73a0f51cdf">yyjson_mut_val_write</a></div><div class="ttdeci">yyjson_api_inline char * yyjson_mut_val_write(const yyjson_mut_val *val, yyjson_write_flag flg, size_t *len)</div><div class="ttdef"><b>Definition</b> yyjson.h:1670</div></div>
<div class="ttc" id="ayyjson_8h_html_afb7989387fc481f678e13325c18e6338"><div class="ttname"><a href="yyjson_8h.html#afb7989387fc481f678e13325c18e6338">yyjson_write_flag</a></div><div class="ttdeci">uint32_t yyjson_write_flag</div><div class="ttdef"><b>Definition</b> yyjson.h:1155</div></div>
</div><!-- fragment --><p>Sample code 1:</p>
<div class="fragment"><div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *doc = <a class="code hl_function" href="yyjson_8h.html#aeab3c2a1d86225e5b181fb1bba7587d4">yyjson_read</a>(<span class="stringliteral">&quot;[1,2,3]&quot;</span>, 7, 0);</div>
<div class="line"><span class="keywordtype">char</span> *json = <a class="code hl_function" href="yyjson_8h.html#ad231975496ac3788fe5d69804e295443">yyjson_write</a>(doc, <a class="code hl_variable" href="yyjson_8h.html#aebdaa55a1673e99d2dcea01a15c633be">YYJSON_WRITE_PRETTY</a>, NULL);</div>
<div class="line">printf(<span class="stringliteral">&quot;%s\n&quot;</span>, json);</div>
<div class="line">free(json);</div>
<div class="ttc" id="ayyjson_8h_html_aebdaa55a1673e99d2dcea01a15c633be"><div class="ttname"><a href="yyjson_8h.html#aebdaa55a1673e99d2dcea01a15c633be">YYJSON_WRITE_PRETTY</a></div><div class="ttdeci">static const yyjson_write_flag YYJSON_WRITE_PRETTY</div><div class="ttdef"><b>Definition</b> yyjson.h:1165</div></div>
</div><!-- fragment --><p>Sample code 2: </p><div class="fragment"><div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc = <a class="code hl_function" href="yyjson_8h.html#ae27cb375110302ec19f4376d7cab3c5b">yyjson_mut_doc_new</a>(NULL);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *arr = <a class="code hl_function" href="yyjson_8h.html#aec0e874c4847338f3b61bf46257cb557">yyjson_mut_arr</a>(doc);</div>
<div class="line"><a class="code hl_function" href="yyjson_8h.html#a8a9f7ea865526acb97ee4eff8d0bb79f">yyjson_mut_doc_set_root</a>(doc, arr);</div>
<div class="line"><a class="code hl_function" href="yyjson_8h.html#ad20aad460c6d7c62f7c371ca5be54667">yyjson_mut_arr_add_int</a>(doc, arr, 1);</div>
<div class="line"><a class="code hl_function" href="yyjson_8h.html#ad20aad460c6d7c62f7c371ca5be54667">yyjson_mut_arr_add_int</a>(doc, arr, 2);</div>
<div class="line"><a class="code hl_function" href="yyjson_8h.html#ad20aad460c6d7c62f7c371ca5be54667">yyjson_mut_arr_add_int</a>(doc, arr, 3);</div>
<div class="line">    </div>
<div class="line"><span class="keywordtype">char</span> *json = <a class="code hl_function" href="yyjson_8h.html#a881e2ee3f487385810829df8bc675f1f">yyjson_mut_write</a>(doc, <a class="code hl_variable" href="yyjson_8h.html#aebdaa55a1673e99d2dcea01a15c633be">YYJSON_WRITE_PRETTY</a>, NULL);</div>
<div class="line">printf(<span class="stringliteral">&quot;%s\n&quot;</span>, json);</div>
<div class="line">free(json);</div>
<div class="ttc" id="ayyjson_8h_html_a8a9f7ea865526acb97ee4eff8d0bb79f"><div class="ttname"><a href="yyjson_8h.html#a8a9f7ea865526acb97ee4eff8d0bb79f">yyjson_mut_doc_set_root</a></div><div class="ttdeci">yyjson_api_inline void yyjson_mut_doc_set_root(yyjson_mut_doc *doc, yyjson_mut_val *root)</div><div class="ttdef"><b>Definition</b> yyjson.h:5705</div></div>
<div class="ttc" id="ayyjson_8h_html_ad20aad460c6d7c62f7c371ca5be54667"><div class="ttname"><a href="yyjson_8h.html#ad20aad460c6d7c62f7c371ca5be54667">yyjson_mut_arr_add_int</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_arr_add_int(yyjson_mut_doc *doc, yyjson_mut_val *arr, int64_t num)</div><div class="ttdef"><b>Definition</b> yyjson.h:6646</div></div>
<div class="ttc" id="ayyjson_8h_html_ae27cb375110302ec19f4376d7cab3c5b"><div class="ttname"><a href="yyjson_8h.html#ae27cb375110302ec19f4376d7cab3c5b">yyjson_mut_doc_new</a></div><div class="ttdeci">yyjson_api yyjson_mut_doc * yyjson_mut_doc_new(const yyjson_alc *alc)</div></div>
<div class="ttc" id="ayyjson_8h_html_aec0e874c4847338f3b61bf46257cb557"><div class="ttname"><a href="yyjson_8h.html#aec0e874c4847338f3b61bf46257cb557">yyjson_mut_arr</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_arr(yyjson_mut_doc *doc)</div><div class="ttdef"><b>Definition</b> yyjson.h:6194</div></div>
</div><!-- fragment --><h2><a class="anchor" id="write-json-to-file"></a>
Write JSON to file</h2>
<p>The <code>path</code> is output JSON file path. This should be a null-terminated string using the system's native encoding. If the path is invalid, you will get an error. If the file is not empty, the content will be discarded. <br  />
 The <code>doc/val</code> is JSON document or root value, if you pass NULL, you will get an error.<br  />
 The <code>flg</code> is writer flag, pass 0 if you don't need it, see <code>writer flag</code> for details.<br  />
 The <code>alc</code> is memory allocator, pass NULL if you don't need it, see <code>memory allocator</code> for details.<br  />
 The <code>err</code> is a pointer to receive error message, pass NULL if you don't need it.<br  />
 This function returns true on success, or false if error occurs.<br  />
</p>
<div class="fragment"><div class="line"><span class="comment">// doc -&gt; file</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a2d82bd0dc78358326b03e28b9acc19e4">yyjson_write_file</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *path, <span class="keyword">const</span> <a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *doc, <a class="code hl_typedef" href="yyjson_8h.html#afb7989387fc481f678e13325c18e6338">yyjson_write_flag</a> flg, <span class="keyword">const</span> <a class="code hl_struct" href="yyjson_8h.html#structyyjson__alc">yyjson_alc</a> *alc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__write__err">yyjson_write_err</a> *err);</div>
<div class="line"><span class="comment">// mut_doc -&gt; file</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#ad2a7aa77fa66a593536e3d7c3edb1d7a">yyjson_mut_write_file</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *path, <span class="keyword">const</span> <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_typedef" href="yyjson_8h.html#afb7989387fc481f678e13325c18e6338">yyjson_write_flag</a> flg, <span class="keyword">const</span> <a class="code hl_struct" href="yyjson_8h.html#structyyjson__alc">yyjson_alc</a> *alc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__write__err">yyjson_write_err</a> *err);</div>
<div class="line"><span class="comment">// val -&gt; file</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a725cc27bd7bd37c1d18c41589abd34db">yyjson_val_write_file</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *path, <span class="keyword">const</span> <a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val, <a class="code hl_typedef" href="yyjson_8h.html#afb7989387fc481f678e13325c18e6338">yyjson_write_flag</a> flg, <span class="keyword">const</span> <a class="code hl_struct" href="yyjson_8h.html#structyyjson__alc">yyjson_alc</a> *alc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__write__err">yyjson_write_err</a> *err);</div>
<div class="line"><span class="comment">// mut_val -&gt; file</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#adf8b2d3c8b57e85d58108d58c68b0db5">yyjson_mut_val_write_file</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *path, <span class="keyword">const</span> <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *val, <a class="code hl_typedef" href="yyjson_8h.html#afb7989387fc481f678e13325c18e6338">yyjson_write_flag</a> flg, <span class="keyword">const</span> <a class="code hl_struct" href="yyjson_8h.html#structyyjson__alc">yyjson_alc</a> *alc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__write__err">yyjson_write_err</a> *err);</div>
<div class="ttc" id="ayyjson_8h_html_a2d82bd0dc78358326b03e28b9acc19e4"><div class="ttname"><a href="yyjson_8h.html#a2d82bd0dc78358326b03e28b9acc19e4">yyjson_write_file</a></div><div class="ttdeci">yyjson_api bool yyjson_write_file(const char *path, const yyjson_doc *doc, yyjson_write_flag flg, const yyjson_alc *alc, yyjson_write_err *err)</div></div>
<div class="ttc" id="ayyjson_8h_html_a725cc27bd7bd37c1d18c41589abd34db"><div class="ttname"><a href="yyjson_8h.html#a725cc27bd7bd37c1d18c41589abd34db">yyjson_val_write_file</a></div><div class="ttdeci">yyjson_api bool yyjson_val_write_file(const char *path, const yyjson_val *val, yyjson_write_flag flg, const yyjson_alc *alc, yyjson_write_err *err)</div></div>
<div class="ttc" id="ayyjson_8h_html_ad2a7aa77fa66a593536e3d7c3edb1d7a"><div class="ttname"><a href="yyjson_8h.html#ad2a7aa77fa66a593536e3d7c3edb1d7a">yyjson_mut_write_file</a></div><div class="ttdeci">yyjson_api bool yyjson_mut_write_file(const char *path, const yyjson_mut_doc *doc, yyjson_write_flag flg, const yyjson_alc *alc, yyjson_write_err *err)</div></div>
<div class="ttc" id="ayyjson_8h_html_adf8b2d3c8b57e85d58108d58c68b0db5"><div class="ttname"><a href="yyjson_8h.html#adf8b2d3c8b57e85d58108d58c68b0db5">yyjson_mut_val_write_file</a></div><div class="ttdeci">yyjson_api bool yyjson_mut_val_write_file(const char *path, const yyjson_mut_val *val, yyjson_write_flag flg, const yyjson_alc *alc, yyjson_write_err *err)</div></div>
<div class="ttc" id="ayyjson_8h_html_structyyjson__write__err"><div class="ttname"><a href="yyjson_8h.html#structyyjson__write__err">yyjson_write_err</a></div><div class="ttdef"><b>Definition</b> yyjson.h:1247</div></div>
</div><!-- fragment --><p>Sample code:</p>
<div class="fragment"><div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *doc = <a class="code hl_function" href="yyjson_8h.html#a605ac08b083fb65331d7fa5eb5d32225">yyjson_read_file</a>(<span class="stringliteral">&quot;/tmp/test.json&quot;</span>, 0, NULL, NULL);</div>
<div class="line"><span class="keywordtype">bool</span> suc = <a class="code hl_function" href="yyjson_8h.html#a2d82bd0dc78358326b03e28b9acc19e4">yyjson_write_file</a>(<span class="stringliteral">&quot;tmp/test.json&quot;</span>, doc, <a class="code hl_variable" href="yyjson_8h.html#aebdaa55a1673e99d2dcea01a15c633be">YYJSON_WRITE_PRETTY</a>, NULL, NULL);</div>
<div class="line"><span class="keywordflow">if</span> (suc) printf(<span class="stringliteral">&quot;OK&quot;</span>);</div>
</div><!-- fragment --><h2><a class="anchor" id="write-json-to-file-pointer"></a>
Write JSON to file pointer</h2>
<p>The <code>fp</code> is output file pointer, The data will be written to the current position of the file.<br  />
 The <code>doc/val</code> is JSON document or root value, if you pass NULL, you will get an error.<br  />
 The <code>flg</code> is writer flag, pass 0 if you don't need it, see <code>writer flag</code> for details.<br  />
 The <code>alc</code> is memory allocator, pass NULL if you don't need it, see <code>memory allocator</code> for details.<br  />
 The <code>err</code> is a pointer to receive error message, pass NULL if you don't need it.<br  />
 This function returns true on success, or false if error occurs.<br  />
</p>
<div class="fragment"><div class="line"><span class="comment">// doc -&gt; file</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a29eea00c04954094701bd90235a7073e">yyjson_write_fp</a>(FILE *fp, <span class="keyword">const</span> <a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *doc, <a class="code hl_typedef" href="yyjson_8h.html#afb7989387fc481f678e13325c18e6338">yyjson_write_flag</a> flg, <span class="keyword">const</span> <a class="code hl_struct" href="yyjson_8h.html#structyyjson__alc">yyjson_alc</a> *alc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__write__err">yyjson_write_err</a> *err);</div>
<div class="line"><span class="comment">// mut_doc -&gt; file</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#ac8c17e7086a6d0a8db559ce0076c71e0">yyjson_mut_write_fp</a>(FILE *fp, <span class="keyword">const</span> <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_typedef" href="yyjson_8h.html#afb7989387fc481f678e13325c18e6338">yyjson_write_flag</a> flg, <span class="keyword">const</span> <a class="code hl_struct" href="yyjson_8h.html#structyyjson__alc">yyjson_alc</a> *alc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__write__err">yyjson_write_err</a> *err);</div>
<div class="line"><span class="comment">// val -&gt; file</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a3e5ad66dd43cc51500fff0926bae21a0">yyjson_val_write_fp</a>(FILE *fp, <span class="keyword">const</span> <a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val, <a class="code hl_typedef" href="yyjson_8h.html#afb7989387fc481f678e13325c18e6338">yyjson_write_flag</a> flg, <span class="keyword">const</span> <a class="code hl_struct" href="yyjson_8h.html#structyyjson__alc">yyjson_alc</a> *alc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__write__err">yyjson_write_err</a> *err);</div>
<div class="line"><span class="comment">// mut_val -&gt; file</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#acb80caf1bf1aecd6b68f38b84628c492">yyjson_mut_val_write_fp</a>(FILE *fp, <span class="keyword">const</span> <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *val, <a class="code hl_typedef" href="yyjson_8h.html#afb7989387fc481f678e13325c18e6338">yyjson_write_flag</a> flg, <span class="keyword">const</span> <a class="code hl_struct" href="yyjson_8h.html#structyyjson__alc">yyjson_alc</a> *alc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__write__err">yyjson_write_err</a> *err);</div>
<div class="ttc" id="ayyjson_8h_html_a29eea00c04954094701bd90235a7073e"><div class="ttname"><a href="yyjson_8h.html#a29eea00c04954094701bd90235a7073e">yyjson_write_fp</a></div><div class="ttdeci">yyjson_api bool yyjson_write_fp(FILE *fp, const yyjson_doc *doc, yyjson_write_flag flg, const yyjson_alc *alc, yyjson_write_err *err)</div></div>
<div class="ttc" id="ayyjson_8h_html_a3e5ad66dd43cc51500fff0926bae21a0"><div class="ttname"><a href="yyjson_8h.html#a3e5ad66dd43cc51500fff0926bae21a0">yyjson_val_write_fp</a></div><div class="ttdeci">yyjson_api bool yyjson_val_write_fp(FILE *fp, const yyjson_val *val, yyjson_write_flag flg, const yyjson_alc *alc, yyjson_write_err *err)</div></div>
<div class="ttc" id="ayyjson_8h_html_ac8c17e7086a6d0a8db559ce0076c71e0"><div class="ttname"><a href="yyjson_8h.html#ac8c17e7086a6d0a8db559ce0076c71e0">yyjson_mut_write_fp</a></div><div class="ttdeci">yyjson_api bool yyjson_mut_write_fp(FILE *fp, const yyjson_mut_doc *doc, yyjson_write_flag flg, const yyjson_alc *alc, yyjson_write_err *err)</div></div>
<div class="ttc" id="ayyjson_8h_html_acb80caf1bf1aecd6b68f38b84628c492"><div class="ttname"><a href="yyjson_8h.html#acb80caf1bf1aecd6b68f38b84628c492">yyjson_mut_val_write_fp</a></div><div class="ttdeci">yyjson_api bool yyjson_mut_val_write_fp(FILE *fp, const yyjson_mut_val *val, yyjson_write_flag flg, const yyjson_alc *alc, yyjson_write_err *err)</div></div>
</div><!-- fragment --><p>Sample code:</p>
<div class="fragment"><div class="line">FILE *fp = fdopen(fd, <span class="stringliteral">&quot;wb&quot;</span>); <span class="comment">// POSIX file descriptor (fd)</span></div>
<div class="line"><span class="keywordtype">bool</span> suc = <a class="code hl_function" href="yyjson_8h.html#a29eea00c04954094701bd90235a7073e">yyjson_write_fp</a>(fp, doc, <a class="code hl_variable" href="yyjson_8h.html#aebdaa55a1673e99d2dcea01a15c633be">YYJSON_WRITE_PRETTY</a>, NULL, NULL);</div>
<div class="line"><span class="keywordflow">if</span> (fp) fclose(fp);</div>
<div class="line"><span class="keywordflow">if</span> (suc) printf(<span class="stringliteral">&quot;OK&quot;</span>);</div>
</div><!-- fragment --><h2><a class="anchor" id="write-json-with-options"></a>
Write JSON with options</h2>
<p>The <code>doc/val</code> is JSON document or root value, if you pass NULL, you will get NULL result.<br  />
 The <code>flg</code> is writer flag, pass 0 if you don't need it, see <code>writer flag</code> for details.<br  />
 The <code>alc</code> is memory allocator, pass NULL if you don't need it, see <code>memory allocator</code> for details.<br  />
 The <code>len</code> is a pointer to receive output length (not including the null-terminator), pass NULL if you don't need it.<br  />
 The <code>err</code> is a pointer to receive error message, pass NULL if you don't need it.<br  />
</p>
<p>This function returns a new JSON string, or NULL if error occurs.<br  />
 The string is encoded as UTF-8 with a null-terminator. <br  />
 You should use free() or alc-&gt;free() to release it when it's no longer needed.</p>
<div class="fragment"><div class="line"><span class="keywordtype">char</span> *<a class="code hl_function" href="yyjson_8h.html#a43ccc01254525cef16699e72079e3e49">yyjson_write_opts</a>(<span class="keyword">const</span> <a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *doc, <a class="code hl_typedef" href="yyjson_8h.html#afb7989387fc481f678e13325c18e6338">yyjson_write_flag</a> flg, <span class="keyword">const</span> <a class="code hl_struct" href="yyjson_8h.html#structyyjson__alc">yyjson_alc</a> *alc, <span class="keywordtype">size_t</span> *len, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__write__err">yyjson_write_err</a> *err);</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">char</span> *<a class="code hl_function" href="yyjson_8h.html#a7af42d62aa1583986c687c5cd10b010e">yyjson_mut_write_opts</a>(<span class="keyword">const</span> <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_typedef" href="yyjson_8h.html#afb7989387fc481f678e13325c18e6338">yyjson_write_flag</a> flg, <span class="keyword">const</span> <a class="code hl_struct" href="yyjson_8h.html#structyyjson__alc">yyjson_alc</a> *alc, <span class="keywordtype">size_t</span> *len, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__write__err">yyjson_write_err</a> *err);</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">char</span> *<a class="code hl_function" href="yyjson_8h.html#a79720744960c9b4fdabbfb28379bbeb4">yyjson_val_write_opts</a>(<span class="keyword">const</span> <a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val, <a class="code hl_typedef" href="yyjson_8h.html#afb7989387fc481f678e13325c18e6338">yyjson_write_flag</a> flg, <span class="keyword">const</span> <a class="code hl_struct" href="yyjson_8h.html#structyyjson__alc">yyjson_alc</a> *alc, <span class="keywordtype">size_t</span> *len, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__write__err">yyjson_write_err</a> *err);</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">char</span> *<a class="code hl_function" href="yyjson_8h.html#abdaf14b79fe803289070c0e5d5a705b8">yyjson_mut_val_write_opts</a>(<span class="keyword">const</span> <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *val, <a class="code hl_typedef" href="yyjson_8h.html#afb7989387fc481f678e13325c18e6338">yyjson_write_flag</a> flg, <span class="keyword">const</span> <a class="code hl_struct" href="yyjson_8h.html#structyyjson__alc">yyjson_alc</a> *alc, <span class="keywordtype">size_t</span> *len, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__write__err">yyjson_write_err</a> *err);</div>
<div class="ttc" id="ayyjson_8h_html_a43ccc01254525cef16699e72079e3e49"><div class="ttname"><a href="yyjson_8h.html#a43ccc01254525cef16699e72079e3e49">yyjson_write_opts</a></div><div class="ttdeci">yyjson_api char * yyjson_write_opts(const yyjson_doc *doc, yyjson_write_flag flg, const yyjson_alc *alc, size_t *len, yyjson_write_err *err)</div></div>
<div class="ttc" id="ayyjson_8h_html_a79720744960c9b4fdabbfb28379bbeb4"><div class="ttname"><a href="yyjson_8h.html#a79720744960c9b4fdabbfb28379bbeb4">yyjson_val_write_opts</a></div><div class="ttdeci">yyjson_api char * yyjson_val_write_opts(const yyjson_val *val, yyjson_write_flag flg, const yyjson_alc *alc, size_t *len, yyjson_write_err *err)</div></div>
<div class="ttc" id="ayyjson_8h_html_a7af42d62aa1583986c687c5cd10b010e"><div class="ttname"><a href="yyjson_8h.html#a7af42d62aa1583986c687c5cd10b010e">yyjson_mut_write_opts</a></div><div class="ttdeci">yyjson_api char * yyjson_mut_write_opts(const yyjson_mut_doc *doc, yyjson_write_flag flg, const yyjson_alc *alc, size_t *len, yyjson_write_err *err)</div></div>
<div class="ttc" id="ayyjson_8h_html_abdaf14b79fe803289070c0e5d5a705b8"><div class="ttname"><a href="yyjson_8h.html#abdaf14b79fe803289070c0e5d5a705b8">yyjson_mut_val_write_opts</a></div><div class="ttdeci">yyjson_api char * yyjson_mut_val_write_opts(const yyjson_mut_val *val, yyjson_write_flag flg, const yyjson_alc *alc, size_t *len, yyjson_write_err *err)</div></div>
</div><!-- fragment --><p>Sample code:</p>
<div class="fragment"><div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *doc = ...;</div>
<div class="line"> </div>
<div class="line"><span class="comment">// init an allocator with stack memory</span></div>
<div class="line"><span class="keywordtype">char</span> buf[64 * 1024];</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__alc">yyjson_alc</a> alc;</div>
<div class="line"><a class="code hl_function" href="yyjson_8h.html#a6068c4293a2b35493b18421b9afbd3d5">yyjson_alc_pool_init</a>(&amp;alc, buf, <span class="keyword">sizeof</span>(buf));</div>
<div class="line"> </div>
<div class="line"><span class="comment">// write</span></div>
<div class="line"><span class="keywordtype">size_t</span> len;</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__write__err">yyjson_write_err</a> err;</div>
<div class="line"><span class="keywordtype">char</span> *json = <a class="code hl_function" href="yyjson_8h.html#a43ccc01254525cef16699e72079e3e49">yyjson_write_opts</a>(doc, <a class="code hl_variable" href="yyjson_8h.html#aebdaa55a1673e99d2dcea01a15c633be">YYJSON_WRITE_PRETTY</a> | <a class="code hl_variable" href="yyjson_8h.html#ac234e82f7a1203e656bcbb0af2ce8c01">YYJSON_WRITE_ESCAPE_UNICODE</a>, &amp;alc, &amp;len, &amp;err);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// get result</span></div>
<div class="line"><span class="keywordflow">if</span> (json) {</div>
<div class="line">    printf(<span class="stringliteral">&quot;suc: %lu\n%s\n&quot;</span>, len, json);</div>
<div class="line">} <span class="keywordflow">else</span> {</div>
<div class="line">    printf(<span class="stringliteral">&quot;err: %u msg:%s\n&quot;</span>, err.<a class="code hl_variable" href="yyjson_8h.html#ae4aa66c2b00d3173291dd48ae398b1c0">code</a>, err.<a class="code hl_variable" href="yyjson_8h.html#a3db87979e01ea1d86ce073b9e7218fe9">msg</a>);</div>
<div class="line">}</div>
<div class="line">alc.<a class="code hl_variable" href="yyjson_8h.html#a2c770ff93f0f331bd60076eecd93661e">free</a>(alc.<a class="code hl_variable" href="yyjson_8h.html#ae9499246c39efd68c206280de1b31f45">ctx</a>, json);</div>
<div class="ttc" id="ayyjson_8h_html_a2c770ff93f0f331bd60076eecd93661e"><div class="ttname"><a href="yyjson_8h.html#a2c770ff93f0f331bd60076eecd93661e">yyjson_alc::free</a></div><div class="ttdeci">void(* free)(void *ctx, void *ptr)</div><div class="ttdef"><b>Definition</b> yyjson.h:592</div></div>
<div class="ttc" id="ayyjson_8h_html_a3db87979e01ea1d86ce073b9e7218fe9"><div class="ttname"><a href="yyjson_8h.html#a3db87979e01ea1d86ce073b9e7218fe9">yyjson_write_err::msg</a></div><div class="ttdeci">const char * msg</div><div class="ttdef"><b>Definition</b> yyjson.h:1251</div></div>
<div class="ttc" id="ayyjson_8h_html_a6068c4293a2b35493b18421b9afbd3d5"><div class="ttname"><a href="yyjson_8h.html#a6068c4293a2b35493b18421b9afbd3d5">yyjson_alc_pool_init</a></div><div class="ttdeci">yyjson_api bool yyjson_alc_pool_init(yyjson_alc *alc, void *buf, size_t size)</div></div>
<div class="ttc" id="ayyjson_8h_html_ac234e82f7a1203e656bcbb0af2ce8c01"><div class="ttname"><a href="yyjson_8h.html#ac234e82f7a1203e656bcbb0af2ce8c01">YYJSON_WRITE_ESCAPE_UNICODE</a></div><div class="ttdeci">static const yyjson_write_flag YYJSON_WRITE_ESCAPE_UNICODE</div><div class="ttdef"><b>Definition</b> yyjson.h:1168</div></div>
<div class="ttc" id="ayyjson_8h_html_ae4aa66c2b00d3173291dd48ae398b1c0"><div class="ttname"><a href="yyjson_8h.html#ae4aa66c2b00d3173291dd48ae398b1c0">yyjson_write_err::code</a></div><div class="ttdeci">yyjson_write_code code</div><div class="ttdef"><b>Definition</b> yyjson.h:1249</div></div>
<div class="ttc" id="ayyjson_8h_html_ae9499246c39efd68c206280de1b31f45"><div class="ttname"><a href="yyjson_8h.html#ae9499246c39efd68c206280de1b31f45">yyjson_alc::ctx</a></div><div class="ttdeci">void * ctx</div><div class="ttdef"><b>Definition</b> yyjson.h:594</div></div>
</div><!-- fragment --><h2><a class="anchor" id="writer-flag"></a>
Writer flag</h2>
<p>The library provides a set of flags for JSON writer.<br  />
 You can use a single flag, or combine multiple flags with bitwise <code>|</code> operator.</p>
<h3><a class="anchor" id="yyjson_write_noflag--0"></a>
<b>YYJSON_WRITE_NOFLAG = 0</b></h3>
<p>This is the default flag for JSON writer:</p>
<ul>
<li>Writes JSON in minified format.</li>
<li>Reports an error on encountering <code>inf</code> or <code>nan</code> number.</li>
<li>Reports an error on encountering invalid UTF-8 strings.</li>
<li>Does not escape unicode or slashes.</li>
</ul>
<h3><a class="anchor" id="yyjson_write_pretty"></a>
<b>YYJSON_WRITE_PRETTY</b></h3>
<p>Writes JSON with a pretty format uing a 4-space indent.</p>
<h3><a class="anchor" id="yyjson_write_pretty_two_spaces"></a>
<b>YYJSON_WRITE_PRETTY_TWO_SPACES</b></h3>
<p>Writes JSON with a pretty format uing a 2-space indent. This flag will override <code>YYJSON_WRITE_PRETTY</code> flag.</p>
<h3><a class="anchor" id="yyjson_write_escape_unicode"></a>
<b>YYJSON_WRITE_ESCAPE_UNICODE</b></h3>
<p>Escape unicode as <code>\uXXXX</code>, making the output ASCII-only, for example:</p>
<div class="fragment"><div class="line">[&quot;Alizée, 😊&quot;]</div>
<div class="line">[&quot;Aliz\\u00E9e, \\uD83D\\uDE0A&quot;]</div>
</div><!-- fragment --><h3><a class="anchor" id="yyjson_write_escape_slashes"></a>
<b>YYJSON_WRITE_ESCAPE_SLASHES</b></h3>
<p>Escapes the forward slash character <code>/</code> as <code>\/</code>, for example:</p>
<div class="fragment"><div class="line">[&quot;https://github.com&quot;]</div>
<div class="line">[&quot;https:\/\/github.com&quot;]</div>
</div><!-- fragment --><h3><a class="anchor" id="yyjson_write_allow_inf_and_nan"></a>
<b>YYJSON_WRITE_ALLOW_INF_AND_NAN</b></h3>
<p>Writes inf/nan numbers as <code>Infinity</code> and <code>NaN</code> literals instead of reporting errors.<br  />
</p>
<p>Note that this output is <b>NOT</b> standard JSON and may be rejected by other JSON libraries, for example:</p>
<div class="fragment"><div class="line">{&quot;not_a_number&quot;:NaN,&quot;large_number&quot;:Infinity}</div>
</div><!-- fragment --><h3><a class="anchor" id="yyjson_write_inf_and_nan_as_null"></a>
<b>YYJSON_WRITE_INF_AND_NAN_AS_NULL</b></h3>
<p>Writes inf/nan numbers as <code>null</code> literals instead of reporting errors.<br  />
 This flag will override <code>YYJSON_WRITE_ALLOW_INF_AND_NAN</code> flag, for example:</p>
<div class="fragment"><div class="line">{&quot;not_a_number&quot;:null,&quot;large_number&quot;:null}</div>
</div><!-- fragment --><h3><a class="anchor" id="yyjson_write_allow_invalid_unicode"></a>
<b>YYJSON_WRITE_ALLOW_INVALID_UNICODE</b></h3>
<p>Allows invalid unicode when encoding string values.</p>
<p>Invalid characters within string values will be copied byte by byte. If <code>YYJSON_WRITE_ESCAPE_UNICODE</code> flag is also set, invalid characters will be escaped as <code>\uFFFD</code> (replacement character).</p>
<p>This flag does not affect the performance of correctly encoded string.</p>
<h3><a class="anchor" id="yyjson_write_newline_at_end"></a>
<b>YYJSON_WRITE_NEWLINE_AT_END</b></h3>
<p>Adds a newline character <code>\n</code> at the end of the JSON. This can be helpful for text editors or NDJSON.</p>
<h3><a class="anchor" id="yyjson_write_fp_to_float"></a>
<b>YYJSON_WRITE_FP_TO_FLOAT</b></h3>
<p>Write floating-point numbers using single-precision (float). This casts <code>double</code> to <code>float</code> before serialization. This will produce shorter output, but may lose some precision. This flag is ignored if <code><a class="el" href="yyjson_8h.html#aa6456ada04bdbe304c1f3fb14e309ac6">YYJSON_WRITE_FP_TO_FIXED(prec)</a></code> is also used.</p>
<h3><a class="anchor" id="yyjson_write_fp_to_fixedprec"></a>
<b>YYJSON_WRITE_FP_TO_FIXED(prec)</b></h3>
<p>Write floating-point number using fixed-point notation. This is similar to ECMAScript <code>Number.prototype.toFixed(prec)</code>, but with trailing zeros removed. The <code>prec</code> ranges from 1 to 15. This will produce shorter output but may lose some precision.</p>
<hr  />
 <h1><a class="anchor" id="accessing-json-document"></a>
Accessing JSON Document</h1>
<h2><a class="anchor" id="json-document"></a>
JSON Document</h2>
<p>You can access the content of a document with the following functions: </p><div class="fragment"><div class="line"><span class="comment">// Get the root value of this JSON document.</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *<a class="code hl_function" href="yyjson_8h.html#aa33a13a85b840b3dbc1f8534db2bd8fc">yyjson_doc_get_root</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *doc);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Get how many bytes are read when parsing JSON.</span></div>
<div class="line"><span class="comment">// e.g. &quot;[1,2,3]&quot; returns 7.</span></div>
<div class="line"><span class="keywordtype">size_t</span> <a class="code hl_function" href="yyjson_8h.html#a33580e2537c25685fd1209951dcbc967">yyjson_doc_get_read_size</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *doc);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Get total value count in this JSON document.</span></div>
<div class="line"><span class="comment">// e.g. &quot;[1,2,3]&quot; returns 4 (1 array and 3 numbers).</span></div>
<div class="line"><span class="keywordtype">size_t</span> <a class="code hl_function" href="yyjson_8h.html#a89cb55aebc946e462968a2bcace5ba5a">yyjson_doc_get_val_count</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *doc);</div>
<div class="ttc" id="ayyjson_8h_html_a89cb55aebc946e462968a2bcace5ba5a"><div class="ttname"><a href="yyjson_8h.html#a89cb55aebc946e462968a2bcace5ba5a">yyjson_doc_get_val_count</a></div><div class="ttdeci">yyjson_api_inline size_t yyjson_doc_get_val_count(yyjson_doc *doc)</div><div class="ttdef"><b>Definition</b> yyjson.h:5126</div></div>
<div class="ttc" id="ayyjson_8h_html_aa33a13a85b840b3dbc1f8534db2bd8fc"><div class="ttname"><a href="yyjson_8h.html#aa33a13a85b840b3dbc1f8534db2bd8fc">yyjson_doc_get_root</a></div><div class="ttdeci">yyjson_api_inline yyjson_val * yyjson_doc_get_root(yyjson_doc *doc)</div><div class="ttdef"><b>Definition</b> yyjson.h:5118</div></div>
</div><!-- fragment --><p>A document holds all the memory for its internal values and strings. When you no longer need it, you should release the document and free up all the memory: </p><div class="fragment"><div class="line"><span class="comment">// Free the document; if NULL is passed in, do nothing.</span></div>
<div class="line"><span class="keywordtype">void</span> <a class="code hl_function" href="yyjson_8h.html#adad98bd766cf52d99f2c54dcb120786d">yyjson_doc_free</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *doc);</div>
</div><!-- fragment --><h2><a class="anchor" id="json-value"></a>
JSON Value</h2>
<p>Each JSON Value has a type and subtype, as specified in the table:</p>
<table class="markdownTable">
<tr class="markdownTableHead">
<th class="markdownTableHeadNone">Type   </th><th class="markdownTableHeadNone">Subtype   </th><th class="markdownTableHeadNone"></th></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">YYJSON_TYPE_NONE   </td><td class="markdownTableBodyNone"></td><td class="markdownTableBodyNone">Invalid value    </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">YYJSON_TYPE_RAW   </td><td class="markdownTableBodyNone"></td><td class="markdownTableBodyNone">Raw string    </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">YYJSON_TYPE_NULL   </td><td class="markdownTableBodyNone"></td><td class="markdownTableBodyNone"><code>null</code> literal    </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">YYJSON_TYPE_BOOL   </td><td class="markdownTableBodyNone">YYJSON_SUBTYPE_FALSE   </td><td class="markdownTableBodyNone"><code>false</code> literal    </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">YYJSON_TYPE_BOOL   </td><td class="markdownTableBodyNone">YYJSON_SUBTYPE_TRUE   </td><td class="markdownTableBodyNone"><code>true</code> literal    </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">YYJSON_TYPE_NUM   </td><td class="markdownTableBodyNone">YYJSON_SUBTYPE_UINT   </td><td class="markdownTableBodyNone"><code>uint64_t</code> nummer    </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">YYJSON_TYPE_NUM   </td><td class="markdownTableBodyNone">YYJSON_SUBTYPE_SINT   </td><td class="markdownTableBodyNone"><code>int64_t</code> number    </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">YYJSON_TYPE_NUM   </td><td class="markdownTableBodyNone">YYJSON_SUBTYPE_REAL   </td><td class="markdownTableBodyNone"><code>double</code> number    </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">YYJSON_TYPE_STR   </td><td class="markdownTableBodyNone"></td><td class="markdownTableBodyNone">String value    </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">YYJSON_TYPE_STR   </td><td class="markdownTableBodyNone">YYJSON_SUBTYPE_NOESC   </td><td class="markdownTableBodyNone">String value, no-escape    </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">YYJSON_TYPE_ARR   </td><td class="markdownTableBodyNone"></td><td class="markdownTableBodyNone">Array value    </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">YYJSON_TYPE_OBJ   </td><td class="markdownTableBodyNone"></td><td class="markdownTableBodyNone">Object value   </td></tr>
</table>
<ul>
<li><code>YYJSON_TYPE_NONE</code> means invalid value, it does not appear when the JSON is successfully parsed.</li>
<li><code>YYJSON_TYPE_RAW</code> only appears when the corresponding flag <code>YYJSON_READ_XXX_AS_RAW</code> is used.</li>
<li><code>YYJSON_SUBTYPE_NOESC</code> is used to optimize the writing speed of strings that do not need to be escaped. This subtype is used internally, and the user does not need to handle it.</li>
</ul>
<p>The following functions can be used to determine the type of a JSON value.</p>
<div class="fragment"><div class="line"><span class="comment">// Returns the type and subtype of a JSON value.</span></div>
<div class="line"><span class="comment">// Returns 0 if the input is NULL.</span></div>
<div class="line"><a class="code hl_typedef" href="yyjson_8h.html#a4d30446a286f54e2f95847f3c6669493">yyjson_type</a> <a class="code hl_function" href="yyjson_8h.html#a7d8d98b60284e646b8b22a8341d99a7f">yyjson_get_type</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val);</div>
<div class="line"><a class="code hl_typedef" href="yyjson_8h.html#a012fa5561c6c87879cceee4e0879a6b6">yyjson_subtype</a> <a class="code hl_function" href="yyjson_8h.html#a7435fee591b112fbdcc455fc60b1416b">yyjson_get_subtype</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Returns value&#39;s tag, see `Data Structures` doc for details.</span></div>
<div class="line">uint8_t <a class="code hl_function" href="yyjson_8h.html#a022754b3eabf9ec15a4f8e9d52db015f">yyjson_get_tag</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// returns type description, such as:  </span></div>
<div class="line"><span class="comment">// &quot;null&quot;, &quot;string&quot;, &quot;array&quot;, &quot;object&quot;, &quot;true&quot;, &quot;false&quot;,</span></div>
<div class="line"><span class="comment">// &quot;uint&quot;, &quot;sint&quot;, &quot;real&quot;, &quot;unknown&quot;</span></div>
<div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code hl_function" href="yyjson_8h.html#a489b91cc6038a17ebc90193bc00e9e8b">yyjson_get_type_desc</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Returns true if the JSON value is specified type.</span></div>
<div class="line"><span class="comment">// Returns false if the input is NULL or not the specified type.</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a81cc3185457d7fd86f3818319d7efe18">yyjson_is_null</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val);  <span class="comment">// null</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a527bfefae4532c4061e56d581ec4fc01">yyjson_is_true</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val);  <span class="comment">// true</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a6105e202bdb2e3b0bd1b561722b80afa">yyjson_is_false</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val); <span class="comment">// false</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a2e3dedcd83d286602101018024f21c52">yyjson_is_bool</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val);  <span class="comment">// true/false</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#ac4b6eb9e397730bbb264f64d46cafacf">yyjson_is_uint</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val);  <span class="comment">// uint64_t</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#ac3de217ef6c479380e38f35a2a166477">yyjson_is_sint</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val);  <span class="comment">// int64_t</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a5079543ec26e3634d0d97491195f0daf">yyjson_is_int</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val);   <span class="comment">// uint64_t/int64_t</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a3cf0581ecad48a658da626cf86903f42">yyjson_is_real</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val);  <span class="comment">// double</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#aedbd4efc6436d66382936b8c450a5877">yyjson_is_num</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val);   <span class="comment">// uint64_t/int64_t/double</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a52f3358d27af0b1f1aeb3fe4dc7da1c0">yyjson_is_str</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val);   <span class="comment">// string</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#add7037998fb39b3e2d1b3caf59f9d66a">yyjson_is_arr</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val);   <span class="comment">// array</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#affa9d4c51b9073804d91ef50e3f5ebd6">yyjson_is_obj</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val);   <span class="comment">// object</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a01aace85ea46ac42974d86fb217a5086">yyjson_is_ctn</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val);   <span class="comment">// array/object</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a286c610e7e27b8b4667a93eba2e2fa28">yyjson_is_raw</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val);   <span class="comment">// raw string</span></div>
<div class="ttc" id="ayyjson_8h_html_a012fa5561c6c87879cceee4e0879a6b6"><div class="ttname"><a href="yyjson_8h.html#a012fa5561c6c87879cceee4e0879a6b6">yyjson_subtype</a></div><div class="ttdeci">uint8_t yyjson_subtype</div><div class="ttdef"><b>Definition</b> yyjson.h:538</div></div>
<div class="ttc" id="ayyjson_8h_html_a01aace85ea46ac42974d86fb217a5086"><div class="ttname"><a href="yyjson_8h.html#a01aace85ea46ac42974d86fb217a5086">yyjson_is_ctn</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_is_ctn(yyjson_val *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:5197</div></div>
<div class="ttc" id="ayyjson_8h_html_a022754b3eabf9ec15a4f8e9d52db015f"><div class="ttname"><a href="yyjson_8h.html#a022754b3eabf9ec15a4f8e9d52db015f">yyjson_get_tag</a></div><div class="ttdeci">yyjson_api_inline uint8_t yyjson_get_tag(yyjson_val *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:5215</div></div>
<div class="ttc" id="ayyjson_8h_html_a2e3dedcd83d286602101018024f21c52"><div class="ttname"><a href="yyjson_8h.html#a2e3dedcd83d286602101018024f21c52">yyjson_is_bool</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_is_bool(yyjson_val *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:5161</div></div>
<div class="ttc" id="ayyjson_8h_html_a3cf0581ecad48a658da626cf86903f42"><div class="ttname"><a href="yyjson_8h.html#a3cf0581ecad48a658da626cf86903f42">yyjson_is_real</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_is_real(yyjson_val *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:5177</div></div>
<div class="ttc" id="ayyjson_8h_html_a489b91cc6038a17ebc90193bc00e9e8b"><div class="ttname"><a href="yyjson_8h.html#a489b91cc6038a17ebc90193bc00e9e8b">yyjson_get_type_desc</a></div><div class="ttdeci">yyjson_api_inline const char * yyjson_get_type_desc(yyjson_val *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:5219</div></div>
<div class="ttc" id="ayyjson_8h_html_a4d30446a286f54e2f95847f3c6669493"><div class="ttname"><a href="yyjson_8h.html#a4d30446a286f54e2f95847f3c6669493">yyjson_type</a></div><div class="ttdeci">uint8_t yyjson_type</div><div class="ttdef"><b>Definition</b> yyjson.h:519</div></div>
<div class="ttc" id="ayyjson_8h_html_a5079543ec26e3634d0d97491195f0daf"><div class="ttname"><a href="yyjson_8h.html#a5079543ec26e3634d0d97491195f0daf">yyjson_is_int</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_is_int(yyjson_val *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:5173</div></div>
<div class="ttc" id="ayyjson_8h_html_a527bfefae4532c4061e56d581ec4fc01"><div class="ttname"><a href="yyjson_8h.html#a527bfefae4532c4061e56d581ec4fc01">yyjson_is_true</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_is_true(yyjson_val *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:5153</div></div>
<div class="ttc" id="ayyjson_8h_html_a6105e202bdb2e3b0bd1b561722b80afa"><div class="ttname"><a href="yyjson_8h.html#a6105e202bdb2e3b0bd1b561722b80afa">yyjson_is_false</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_is_false(yyjson_val *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:5157</div></div>
<div class="ttc" id="ayyjson_8h_html_a7435fee591b112fbdcc455fc60b1416b"><div class="ttname"><a href="yyjson_8h.html#a7435fee591b112fbdcc455fc60b1416b">yyjson_get_subtype</a></div><div class="ttdeci">yyjson_api_inline yyjson_subtype yyjson_get_subtype(yyjson_val *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:5211</div></div>
<div class="ttc" id="ayyjson_8h_html_a7d8d98b60284e646b8b22a8341d99a7f"><div class="ttname"><a href="yyjson_8h.html#a7d8d98b60284e646b8b22a8341d99a7f">yyjson_get_type</a></div><div class="ttdeci">yyjson_api_inline yyjson_type yyjson_get_type(yyjson_val *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:5207</div></div>
<div class="ttc" id="ayyjson_8h_html_a81cc3185457d7fd86f3818319d7efe18"><div class="ttname"><a href="yyjson_8h.html#a81cc3185457d7fd86f3818319d7efe18">yyjson_is_null</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_is_null(yyjson_val *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:5149</div></div>
<div class="ttc" id="ayyjson_8h_html_ac3de217ef6c479380e38f35a2a166477"><div class="ttname"><a href="yyjson_8h.html#ac3de217ef6c479380e38f35a2a166477">yyjson_is_sint</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_is_sint(yyjson_val *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:5169</div></div>
<div class="ttc" id="ayyjson_8h_html_ac4b6eb9e397730bbb264f64d46cafacf"><div class="ttname"><a href="yyjson_8h.html#ac4b6eb9e397730bbb264f64d46cafacf">yyjson_is_uint</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_is_uint(yyjson_val *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:5165</div></div>
<div class="ttc" id="ayyjson_8h_html_add7037998fb39b3e2d1b3caf59f9d66a"><div class="ttname"><a href="yyjson_8h.html#add7037998fb39b3e2d1b3caf59f9d66a">yyjson_is_arr</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_is_arr(yyjson_val *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:5189</div></div>
<div class="ttc" id="ayyjson_8h_html_aedbd4efc6436d66382936b8c450a5877"><div class="ttname"><a href="yyjson_8h.html#aedbd4efc6436d66382936b8c450a5877">yyjson_is_num</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_is_num(yyjson_val *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:5181</div></div>
<div class="ttc" id="ayyjson_8h_html_affa9d4c51b9073804d91ef50e3f5ebd6"><div class="ttname"><a href="yyjson_8h.html#affa9d4c51b9073804d91ef50e3f5ebd6">yyjson_is_obj</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_is_obj(yyjson_val *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:5193</div></div>
</div><!-- fragment --><p>The following functions can be used to get the contents of the JSON value.</p>
<div class="fragment"><div class="line"><span class="comment">// Returns the raw string, or NULL if `val` is not raw type.</span></div>
<div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code hl_function" href="yyjson_8h.html#a5e90e838f969425f75372d4b4246d145">yyjson_get_raw</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Returns bool value, or false if `val` is not bool type.</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#aaed218041aa262337e179d487f4c770c">yyjson_get_bool</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Returns uint64_t value, or 0 if `val` is not uint type.</span></div>
<div class="line">uint64_t <a class="code hl_function" href="yyjson_8h.html#ab439bc90f6631a67dd3ed4626eb3b4ad">yyjson_get_uint</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Returns int64_t value, or 0 if `val` is not sint type.</span></div>
<div class="line">int64_t <a class="code hl_function" href="yyjson_8h.html#ac4aab52f91a8b365344a74812be4e712">yyjson_get_sint</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Returns int value (may overflow), or 0 if `val` is not uint/sint type.</span></div>
<div class="line"><span class="keywordtype">int</span> <a class="code hl_function" href="yyjson_8h.html#a383b0a924785a30a49f6c59de235cd28">yyjson_get_int</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Returns double value, or 0 if `val` is not real type.</span></div>
<div class="line"><span class="keywordtype">double</span> <a class="code hl_function" href="yyjson_8h.html#a5bfc74dbba137fc4d662702666f5073a">yyjson_get_real</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Returns double value (typecast), or 0 if `val` is not uint/sint/real type.</span></div>
<div class="line"><span class="keywordtype">double</span> <a class="code hl_function" href="yyjson_8h.html#ac24ffc0726b50f38283c9f01f4e58d9b">yyjson_get_num</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Returns the string value, or NULL if `val` is not string type.</span></div>
<div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code hl_function" href="yyjson_8h.html#a986e994db00b2749e000af0a4331454c">yyjson_get_str</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Returns the content length (string length in bytes, array size, </span></div>
<div class="line"><span class="comment">// object size), or 0 if the value does not contains length data.</span></div>
<div class="line"><span class="keywordtype">size_t</span> <a class="code hl_function" href="yyjson_8h.html#ae4b5e4edc9713d9f48e2a6750ad5ebff">yyjson_get_len</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Returns whether the value is equals to a string.</span></div>
<div class="line"><span class="comment">// Returns false if input is NULL or `val` is not string.</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a147b5b874e6b939731f1b6c15abcbbca">yyjson_equals_str</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val, <span class="keyword">const</span> <span class="keywordtype">char</span> *str);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a1a7a91be15978b45345976c8432769aa">yyjson_equals_strn</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val, <span class="keyword">const</span> <span class="keywordtype">char</span> *str, <span class="keywordtype">size_t</span> len);</div>
<div class="ttc" id="ayyjson_8h_html_a383b0a924785a30a49f6c59de235cd28"><div class="ttname"><a href="yyjson_8h.html#a383b0a924785a30a49f6c59de235cd28">yyjson_get_int</a></div><div class="ttdeci">yyjson_api_inline int yyjson_get_int(yyjson_val *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:5252</div></div>
<div class="ttc" id="ayyjson_8h_html_a5bfc74dbba137fc4d662702666f5073a"><div class="ttname"><a href="yyjson_8h.html#a5bfc74dbba137fc4d662702666f5073a">yyjson_get_real</a></div><div class="ttdeci">yyjson_api_inline double yyjson_get_real(yyjson_val *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:5256</div></div>
<div class="ttc" id="ayyjson_8h_html_a986e994db00b2749e000af0a4331454c"><div class="ttname"><a href="yyjson_8h.html#a986e994db00b2749e000af0a4331454c">yyjson_get_str</a></div><div class="ttdeci">yyjson_api_inline const char * yyjson_get_str(yyjson_val *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:5264</div></div>
<div class="ttc" id="ayyjson_8h_html_aaed218041aa262337e179d487f4c770c"><div class="ttname"><a href="yyjson_8h.html#aaed218041aa262337e179d487f4c770c">yyjson_get_bool</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_get_bool(yyjson_val *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:5240</div></div>
<div class="ttc" id="ayyjson_8h_html_ab439bc90f6631a67dd3ed4626eb3b4ad"><div class="ttname"><a href="yyjson_8h.html#ab439bc90f6631a67dd3ed4626eb3b4ad">yyjson_get_uint</a></div><div class="ttdeci">yyjson_api_inline uint64_t yyjson_get_uint(yyjson_val *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:5244</div></div>
<div class="ttc" id="ayyjson_8h_html_ac24ffc0726b50f38283c9f01f4e58d9b"><div class="ttname"><a href="yyjson_8h.html#ac24ffc0726b50f38283c9f01f4e58d9b">yyjson_get_num</a></div><div class="ttdeci">yyjson_api_inline double yyjson_get_num(yyjson_val *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:5260</div></div>
<div class="ttc" id="ayyjson_8h_html_ac4aab52f91a8b365344a74812be4e712"><div class="ttname"><a href="yyjson_8h.html#ac4aab52f91a8b365344a74812be4e712">yyjson_get_sint</a></div><div class="ttdeci">yyjson_api_inline int64_t yyjson_get_sint(yyjson_val *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:5248</div></div>
</div><!-- fragment --><p>The following functions can be used to modify the content of a JSON value.<br  />
</p>
<p>Warning: For immutable documents, these functions will break the <code>immutable</code> convention, you should use this set of APIs with caution (e.g. make sure the document is only accessed in a single thread).</p>
<div class="fragment"><div class="line"><span class="comment">// Set the value to new type and content.</span></div>
<div class="line"><span class="comment">// Returns false if input is NULL or `val` is object or array.</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a75ee22602fb750b67fda804fb653ef1e">yyjson_set_raw</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val, <span class="keyword">const</span> <span class="keywordtype">char</span> *raw, <span class="keywordtype">size_t</span> len);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a079fdf2d481492c8533104437dbf2283">yyjson_set_null</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#ad99ceda574b466f8102699e52564c8da">yyjson_set_bool</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val, <span class="keywordtype">bool</span> num);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a90614444c9d6bbd7d8586176986adbc5">yyjson_set_uint</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val, uint64_t num);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#ad0f58bd6ac0289fd55d09b02fa3d4743">yyjson_set_sint</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val, int64_t num);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#af1f4dd90c0bd891cb139e72cfd588789">yyjson_set_int</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val, <span class="keywordtype">int</span> num);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#aae763338f1c11ad9da6be1cf522daf6e">yyjson_set_float</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val, <span class="keywordtype">float</span> num);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#acfc9cec2bb59669d777fe219730793b8">yyjson_set_double</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val, <span class="keywordtype">double</span> num);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#ac782a838c6378f022434d7ab3a3b333d">yyjson_set_real</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val, <span class="keywordtype">double</span> num);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// The string is not copied, should be held by caller.</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a9a0f4082d2244b7264a819bbc32ebbdf">yyjson_set_str</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val, <span class="keyword">const</span> <span class="keywordtype">char</span> *str);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a9e49dc52b6209708df0ccf4ddf49b8c4">yyjson_set_strn</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val, <span class="keyword">const</span> <span class="keywordtype">char</span> *str, <span class="keywordtype">size_t</span> len);</div>
<div class="ttc" id="ayyjson_8h_html_a079fdf2d481492c8533104437dbf2283"><div class="ttname"><a href="yyjson_8h.html#a079fdf2d481492c8533104437dbf2283">yyjson_set_null</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_set_null(yyjson_val *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:5303</div></div>
<div class="ttc" id="ayyjson_8h_html_a75ee22602fb750b67fda804fb653ef1e"><div class="ttname"><a href="yyjson_8h.html#a75ee22602fb750b67fda804fb653ef1e">yyjson_set_raw</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_set_raw(yyjson_val *val, const char *raw, size_t len)</div><div class="ttdef"><b>Definition</b> yyjson.h:5296</div></div>
<div class="ttc" id="ayyjson_8h_html_a90614444c9d6bbd7d8586176986adbc5"><div class="ttname"><a href="yyjson_8h.html#a90614444c9d6bbd7d8586176986adbc5">yyjson_set_uint</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_set_uint(yyjson_val *val, uint64_t num)</div><div class="ttdef"><b>Definition</b> yyjson.h:5315</div></div>
<div class="ttc" id="ayyjson_8h_html_a9a0f4082d2244b7264a819bbc32ebbdf"><div class="ttname"><a href="yyjson_8h.html#a9a0f4082d2244b7264a819bbc32ebbdf">yyjson_set_str</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_set_str(yyjson_val *val, const char *str)</div><div class="ttdef"><b>Definition</b> yyjson.h:5363</div></div>
<div class="ttc" id="ayyjson_8h_html_a9e49dc52b6209708df0ccf4ddf49b8c4"><div class="ttname"><a href="yyjson_8h.html#a9e49dc52b6209708df0ccf4ddf49b8c4">yyjson_set_strn</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_set_strn(yyjson_val *val, const char *str, size_t len)</div><div class="ttdef"><b>Definition</b> yyjson.h:5370</div></div>
<div class="ttc" id="ayyjson_8h_html_aae763338f1c11ad9da6be1cf522daf6e"><div class="ttname"><a href="yyjson_8h.html#aae763338f1c11ad9da6be1cf522daf6e">yyjson_set_float</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_set_float(yyjson_val *val, float num)</div><div class="ttdef"><b>Definition</b> yyjson.h:5333</div></div>
<div class="ttc" id="ayyjson_8h_html_ac782a838c6378f022434d7ab3a3b333d"><div class="ttname"><a href="yyjson_8h.html#ac782a838c6378f022434d7ab3a3b333d">yyjson_set_real</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_set_real(yyjson_val *val, double num)</div><div class="ttdef"><b>Definition</b> yyjson.h:5345</div></div>
<div class="ttc" id="ayyjson_8h_html_acfc9cec2bb59669d777fe219730793b8"><div class="ttname"><a href="yyjson_8h.html#acfc9cec2bb59669d777fe219730793b8">yyjson_set_double</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_set_double(yyjson_val *val, double num)</div><div class="ttdef"><b>Definition</b> yyjson.h:5339</div></div>
<div class="ttc" id="ayyjson_8h_html_ad0f58bd6ac0289fd55d09b02fa3d4743"><div class="ttname"><a href="yyjson_8h.html#ad0f58bd6ac0289fd55d09b02fa3d4743">yyjson_set_sint</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_set_sint(yyjson_val *val, int64_t num)</div><div class="ttdef"><b>Definition</b> yyjson.h:5321</div></div>
<div class="ttc" id="ayyjson_8h_html_ad99ceda574b466f8102699e52564c8da"><div class="ttname"><a href="yyjson_8h.html#ad99ceda574b466f8102699e52564c8da">yyjson_set_bool</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_set_bool(yyjson_val *val, bool num)</div><div class="ttdef"><b>Definition</b> yyjson.h:5309</div></div>
<div class="ttc" id="ayyjson_8h_html_af1f4dd90c0bd891cb139e72cfd588789"><div class="ttname"><a href="yyjson_8h.html#af1f4dd90c0bd891cb139e72cfd588789">yyjson_set_int</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_set_int(yyjson_val *val, int num)</div><div class="ttdef"><b>Definition</b> yyjson.h:5327</div></div>
</div><!-- fragment --><h2><a class="anchor" id="json-array"></a>
JSON Array</h2>
<p>The following functions can be used to access a JSON array.<br  />
</p>
<p>Note that accessing elements by index may take a linear search time. Therefore, if you need to iterate through an array, it is recommended to use the iterator API.</p>
<div class="fragment"><div class="line"><span class="comment">// Returns the number of elements in this array.</span></div>
<div class="line"><span class="comment">// Returns 0 if the input is not an array.</span></div>
<div class="line"><span class="keywordtype">size_t</span> <a class="code hl_function" href="yyjson_8h.html#a0ea8514c92f39fd93ddcbe93a7f466e5">yyjson_arr_size</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *arr);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Returns the element at the specified position (linear search time).</span></div>
<div class="line"><span class="comment">// Returns NULL if the index is out of bounds, or input is not an array.</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *<a class="code hl_function" href="yyjson_8h.html#ac709738fbf9da708c28992c40746fcbf">yyjson_arr_get</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *arr, <span class="keywordtype">size_t</span> idx);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Returns the first element of this array (constant time).</span></div>
<div class="line"><span class="comment">// Returns NULL if array is empty or intput is not an array.</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *<a class="code hl_function" href="yyjson_8h.html#ad54c34d490dd8e479e21e4cb29bc814b">yyjson_arr_get_first</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *arr);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Returns the last element of this array (linear search time).</span></div>
<div class="line"><span class="comment">// Returns NULL if array is empty or intput is not an array.</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *<a class="code hl_function" href="yyjson_8h.html#a15bbce96107aa455670ebe9aab98964d">yyjson_arr_get_last</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *arr);</div>
<div class="ttc" id="ayyjson_8h_html_a0ea8514c92f39fd93ddcbe93a7f466e5"><div class="ttname"><a href="yyjson_8h.html#a0ea8514c92f39fd93ddcbe93a7f466e5">yyjson_arr_size</a></div><div class="ttdeci">yyjson_api_inline size_t yyjson_arr_size(yyjson_val *arr)</div><div class="ttdef"><b>Definition</b> yyjson.h:5390</div></div>
<div class="ttc" id="ayyjson_8h_html_a15bbce96107aa455670ebe9aab98964d"><div class="ttname"><a href="yyjson_8h.html#a15bbce96107aa455670ebe9aab98964d">yyjson_arr_get_last</a></div><div class="ttdeci">yyjson_api_inline yyjson_val * yyjson_arr_get_last(yyjson_val *arr)</div><div class="ttdef"><b>Definition</b> yyjson.h:5418</div></div>
<div class="ttc" id="ayyjson_8h_html_ac709738fbf9da708c28992c40746fcbf"><div class="ttname"><a href="yyjson_8h.html#ac709738fbf9da708c28992c40746fcbf">yyjson_arr_get</a></div><div class="ttdeci">yyjson_api_inline yyjson_val * yyjson_arr_get(yyjson_val *arr, size_t idx)</div><div class="ttdef"><b>Definition</b> yyjson.h:5394</div></div>
<div class="ttc" id="ayyjson_8h_html_ad54c34d490dd8e479e21e4cb29bc814b"><div class="ttname"><a href="yyjson_8h.html#ad54c34d490dd8e479e21e4cb29bc814b">yyjson_arr_get_first</a></div><div class="ttdeci">yyjson_api_inline yyjson_val * yyjson_arr_get_first(yyjson_val *arr)</div><div class="ttdef"><b>Definition</b> yyjson.h:5409</div></div>
</div><!-- fragment --><h2><a class="anchor" id="json-array-iterator"></a>
JSON Array Iterator</h2>
<p>There are two ways to traverse an array:<br  />
</p>
<p>Sample code 1 (iterator API): </p><div class="fragment"><div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *arr; <span class="comment">// the array to be traversed</span></div>
<div class="line"> </div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val;</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__arr__iter">yyjson_arr_iter</a> iter = <a class="code hl_function" href="yyjson_8h.html#a38b10c3293b817b25d9dd985da121cb5">yyjson_arr_iter_with</a>(arr);</div>
<div class="line"><span class="keywordflow">while</span> ((val = <a class="code hl_function" href="yyjson_8h.html#ab608a351427921421a2e23877399acd5">yyjson_arr_iter_next</a>(&amp;iter))) {</div>
<div class="line">    your_func(val);</div>
<div class="line">}</div>
<div class="ttc" id="ayyjson_8h_html_a38b10c3293b817b25d9dd985da121cb5"><div class="ttname"><a href="yyjson_8h.html#a38b10c3293b817b25d9dd985da121cb5">yyjson_arr_iter_with</a></div><div class="ttdeci">yyjson_api_inline yyjson_arr_iter yyjson_arr_iter_with(yyjson_val *arr)</div><div class="ttdef"><b>Definition</b> yyjson.h:5452</div></div>
<div class="ttc" id="ayyjson_8h_html_ab608a351427921421a2e23877399acd5"><div class="ttname"><a href="yyjson_8h.html#ab608a351427921421a2e23877399acd5">yyjson_arr_iter_next</a></div><div class="ttdeci">yyjson_api_inline yyjson_val * yyjson_arr_iter_next(yyjson_arr_iter *iter)</div><div class="ttdef"><b>Definition</b> yyjson.h:5462</div></div>
<div class="ttc" id="ayyjson_8h_html_structyyjson__arr__iter"><div class="ttname"><a href="yyjson_8h.html#structyyjson__arr__iter">yyjson_arr_iter</a></div><div class="ttdef"><b>Definition</b> yyjson.h:1990</div></div>
</div><!-- fragment --><p>Sample code 2 (foreach macro): </p><div class="fragment"><div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *arr; <span class="comment">// the array to be traversed</span></div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">size_t</span> idx, max;</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val;</div>
<div class="line"><a class="code hl_define" href="yyjson_8h.html#a60fd8094ee3eff6e7b629471f50aa139">yyjson_arr_foreach</a>(arr, idx, max, val) {</div>
<div class="line">    your_func(idx, val);</div>
<div class="line">}</div>
<div class="ttc" id="ayyjson_8h_html_a60fd8094ee3eff6e7b629471f50aa139"><div class="ttname"><a href="yyjson_8h.html#a60fd8094ee3eff6e7b629471f50aa139">yyjson_arr_foreach</a></div><div class="ttdeci">#define yyjson_arr_foreach(arr, idx, max, val)</div><div class="ttdef"><b>Definition</b> yyjson.h:2046</div></div>
</div><!-- fragment --><p> <br  />
</p>
<p>There's also mutable version API to traverse an mutable array:<br  />
</p>
<p>Sample code 1 (mutable iterator API): </p><div class="fragment"><div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *arr; <span class="comment">// the array to be traversed</span></div>
<div class="line"> </div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *val;</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__arr__iter">yyjson_mut_arr_iter</a> iter = <a class="code hl_function" href="yyjson_8h.html#a9d8bf48b287cc0099eb6619d8b4b712e">yyjson_mut_arr_iter_with</a>(arr);</div>
<div class="line"><span class="keywordflow">while</span> ((val = <a class="code hl_function" href="yyjson_8h.html#a793250c5394193a73b5e9506c8381994">yyjson_mut_arr_iter_next</a>(&amp;iter))) {</div>
<div class="line">    <span class="keywordflow">if</span> (your_val_is_unused(val)) {</div>
<div class="line">        <span class="comment">// you can remove current value inside iteration</span></div>
<div class="line">        <a class="code hl_function" href="yyjson_8h.html#a20fa69856e99295473e1b3e111adc3b1">yyjson_mut_arr_iter_remove</a>(&amp;iter); </div>
<div class="line">    }</div>
<div class="line">}</div>
<div class="ttc" id="ayyjson_8h_html_a20fa69856e99295473e1b3e111adc3b1"><div class="ttname"><a href="yyjson_8h.html#a20fa69856e99295473e1b3e111adc3b1">yyjson_mut_arr_iter_remove</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_iter_remove(yyjson_mut_arr_iter *iter)</div><div class="ttdef"><b>Definition</b> yyjson.h:6171</div></div>
<div class="ttc" id="ayyjson_8h_html_a793250c5394193a73b5e9506c8381994"><div class="ttname"><a href="yyjson_8h.html#a793250c5394193a73b5e9506c8381994">yyjson_mut_arr_iter_next</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_iter_next(yyjson_mut_arr_iter *iter)</div><div class="ttdef"><b>Definition</b> yyjson.h:6159</div></div>
<div class="ttc" id="ayyjson_8h_html_a9d8bf48b287cc0099eb6619d8b4b712e"><div class="ttname"><a href="yyjson_8h.html#a9d8bf48b287cc0099eb6619d8b4b712e">yyjson_mut_arr_iter_with</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_arr_iter yyjson_mut_arr_iter_with(yyjson_mut_val *arr)</div><div class="ttdef"><b>Definition</b> yyjson.h:6148</div></div>
<div class="ttc" id="ayyjson_8h_html_structyyjson__mut__arr__iter"><div class="ttname"><a href="yyjson_8h.html#structyyjson__mut__arr__iter">yyjson_mut_arr_iter</a></div><div class="ttdef"><b>Definition</b> yyjson.h:2711</div></div>
</div><!-- fragment --><p>Sample code 2 (mutable foreach macro): </p><div class="fragment"><div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *arr; <span class="comment">// the array to be traversed</span></div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">size_t</span> idx, max;</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *val;</div>
<div class="line"><a class="code hl_define" href="yyjson_8h.html#a23a525f4192a237730aedfad55798fdb">yyjson_mut_arr_foreach</a>(arr, idx, max, val) {</div>
<div class="line">    your_func(idx, val);</div>
<div class="line">}</div>
<div class="ttc" id="ayyjson_8h_html_a23a525f4192a237730aedfad55798fdb"><div class="ttname"><a href="yyjson_8h.html#a23a525f4192a237730aedfad55798fdb">yyjson_mut_arr_foreach</a></div><div class="ttdeci">#define yyjson_mut_arr_foreach(arr, idx, max, val)</div><div class="ttdef"><b>Definition</b> yyjson.h:2781</div></div>
</div><!-- fragment --><h2><a class="anchor" id="json-object"></a>
JSON Object</h2>
<p>The following functions can be used to access a JSON object.<br  />
</p>
<p>Note that accessing elements by key may take a linear search time. Therefore, if you need to iterate through an object, it is recommended to use the iterator API.</p>
<div class="fragment"><div class="line"><span class="comment">// Returns the number of key-value pairs in this object.</span></div>
<div class="line"><span class="comment">// Returns 0 if input is not an object.</span></div>
<div class="line"><span class="keywordtype">size_t</span> <a class="code hl_function" href="yyjson_8h.html#aa9789f197f972dc433ea2eb622defd50">yyjson_obj_size</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *obj);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Returns the value to which the specified key is mapped.</span></div>
<div class="line"><span class="comment">// Returns NULL if this object contains no mapping for the key.</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *<a class="code hl_function" href="yyjson_8h.html#a1e8a4dea2e9e9248acde14c664ab702b">yyjson_obj_get</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *obj, <span class="keyword">const</span> <span class="keywordtype">char</span> *key);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *<a class="code hl_function" href="yyjson_8h.html#a2936ca2492ae8cdcdf0435f5259ff854">yyjson_obj_getn</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *obj, <span class="keyword">const</span> <span class="keywordtype">char</span> *key, <span class="keywordtype">size_t</span> key_len);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// If the order of object&#39;s key is known at compile-time,</span></div>
<div class="line"><span class="comment">// you can use this method to avoid searching the entire object.</span></div>
<div class="line"><span class="comment">// e.g. { &quot;x&quot;:1, &quot;y&quot;:2, &quot;z&quot;:3 }</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *obj = ...;</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__obj__iter">yyjson_obj_iter</a> iter = <a class="code hl_function" href="yyjson_8h.html#a543806a566821ccc6c7069edabc59a85">yyjson_obj_iter_with</a>(obj);</div>
<div class="line"> </div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *x = <a class="code hl_function" href="yyjson_8h.html#a1f3b09c4f279287f8af93b3754a41e85">yyjson_obj_iter_get</a>(&amp;iter, <span class="stringliteral">&quot;x&quot;</span>);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *z = <a class="code hl_function" href="yyjson_8h.html#a1f3b09c4f279287f8af93b3754a41e85">yyjson_obj_iter_get</a>(&amp;iter, <span class="stringliteral">&quot;z&quot;</span>);</div>
<div class="ttc" id="ayyjson_8h_html_a1e8a4dea2e9e9248acde14c664ab702b"><div class="ttname"><a href="yyjson_8h.html#a1e8a4dea2e9e9248acde14c664ab702b">yyjson_obj_get</a></div><div class="ttdeci">yyjson_api_inline yyjson_val * yyjson_obj_get(yyjson_val *obj, const char *key)</div><div class="ttdef"><b>Definition</b> yyjson.h:5483</div></div>
<div class="ttc" id="ayyjson_8h_html_a1f3b09c4f279287f8af93b3754a41e85"><div class="ttname"><a href="yyjson_8h.html#a1f3b09c4f279287f8af93b3754a41e85">yyjson_obj_iter_get</a></div><div class="ttdeci">yyjson_api_inline yyjson_val * yyjson_obj_iter_get(yyjson_obj_iter *iter, const char *key)</div><div class="ttdef"><b>Definition</b> yyjson.h:5545</div></div>
<div class="ttc" id="ayyjson_8h_html_a2936ca2492ae8cdcdf0435f5259ff854"><div class="ttname"><a href="yyjson_8h.html#a2936ca2492ae8cdcdf0435f5259ff854">yyjson_obj_getn</a></div><div class="ttdeci">yyjson_api_inline yyjson_val * yyjson_obj_getn(yyjson_val *obj, const char *key, size_t key_len)</div><div class="ttdef"><b>Definition</b> yyjson.h:5488</div></div>
<div class="ttc" id="ayyjson_8h_html_a543806a566821ccc6c7069edabc59a85"><div class="ttname"><a href="yyjson_8h.html#a543806a566821ccc6c7069edabc59a85">yyjson_obj_iter_with</a></div><div class="ttdeci">yyjson_api_inline yyjson_obj_iter yyjson_obj_iter_with(yyjson_val *obj)</div><div class="ttdef"><b>Definition</b> yyjson.h:5521</div></div>
<div class="ttc" id="ayyjson_8h_html_aa9789f197f972dc433ea2eb622defd50"><div class="ttname"><a href="yyjson_8h.html#aa9789f197f972dc433ea2eb622defd50">yyjson_obj_size</a></div><div class="ttdeci">yyjson_api_inline size_t yyjson_obj_size(yyjson_val *obj)</div><div class="ttdef"><b>Definition</b> yyjson.h:5479</div></div>
<div class="ttc" id="ayyjson_8h_html_structyyjson__obj__iter"><div class="ttname"><a href="yyjson_8h.html#structyyjson__obj__iter">yyjson_obj_iter</a></div><div class="ttdef"><b>Definition</b> yyjson.h:2114</div></div>
</div><!-- fragment --><h2><a class="anchor" id="json-object-iterator"></a>
JSON Object Iterator</h2>
<p>There are two ways to traverse an object:<br  />
</p>
<p>Sample code 1 (iterator API): </p><div class="fragment"><div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *obj; <span class="comment">// the object to be traversed</span></div>
<div class="line"> </div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *key, *val;</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__obj__iter">yyjson_obj_iter</a> iter = <a class="code hl_function" href="yyjson_8h.html#a543806a566821ccc6c7069edabc59a85">yyjson_obj_iter_with</a>(obj);</div>
<div class="line"><span class="keywordflow">while</span> ((key = <a class="code hl_function" href="yyjson_8h.html#a6033befb82b9331d2c19c09799ec5bcf">yyjson_obj_iter_next</a>(&amp;iter))) {</div>
<div class="line">    val = <a class="code hl_function" href="yyjson_8h.html#a3403b9c25c8b8f2b3027f4e6d97d0ca8">yyjson_obj_iter_get_val</a>(key);</div>
<div class="line">    your_func(key, val);</div>
<div class="line">}</div>
<div class="ttc" id="ayyjson_8h_html_a3403b9c25c8b8f2b3027f4e6d97d0ca8"><div class="ttname"><a href="yyjson_8h.html#a3403b9c25c8b8f2b3027f4e6d97d0ca8">yyjson_obj_iter_get_val</a></div><div class="ttdeci">yyjson_api_inline yyjson_val * yyjson_obj_iter_get_val(yyjson_val *key)</div><div class="ttdef"><b>Definition</b> yyjson.h:5541</div></div>
<div class="ttc" id="ayyjson_8h_html_a6033befb82b9331d2c19c09799ec5bcf"><div class="ttname"><a href="yyjson_8h.html#a6033befb82b9331d2c19c09799ec5bcf">yyjson_obj_iter_next</a></div><div class="ttdeci">yyjson_api_inline yyjson_val * yyjson_obj_iter_next(yyjson_obj_iter *iter)</div><div class="ttdef"><b>Definition</b> yyjson.h:5531</div></div>
</div><!-- fragment --><p>Sample code 2 (foreach macro): </p><div class="fragment"><div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *obj; <span class="comment">// this is your object</span></div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">size_t</span> idx, max;</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *key, *val;</div>
<div class="line"><a class="code hl_define" href="yyjson_8h.html#a32884e21b899ea5869b12aec02083002">yyjson_obj_foreach</a>(obj, idx, max, key, val) {</div>
<div class="line">    your_func(key, val);</div>
<div class="line">}</div>
<div class="ttc" id="ayyjson_8h_html_a32884e21b899ea5869b12aec02083002"><div class="ttname"><a href="yyjson_8h.html#a32884e21b899ea5869b12aec02083002">yyjson_obj_foreach</a></div><div class="ttdeci">#define yyjson_obj_foreach(obj, idx, max, key, val)</div><div class="ttdef"><b>Definition</b> yyjson.h:2217</div></div>
</div><!-- fragment --><p> <br  />
</p>
<p>There's also mutable version API to traverse an mutable object:<br  />
</p>
<p>Sample code 1 (mutable iterator API): </p><div class="fragment"><div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *obj; <span class="comment">// the object to be traversed</span></div>
<div class="line"> </div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *key, *val;</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__obj__iter">yyjson_mut_obj_iter</a> iter = <a class="code hl_function" href="yyjson_8h.html#aedac207e6c2d5e031997e2b0df73db6a">yyjson_mut_obj_iter_with</a>(obj);</div>
<div class="line"><span class="keywordflow">while</span> ((key = <a class="code hl_function" href="yyjson_8h.html#a55f4228c2d65d497ad3cee8abe95c0be">yyjson_mut_obj_iter_next</a>(&amp;iter))) {</div>
<div class="line">    val = <a class="code hl_function" href="yyjson_8h.html#aaa4bef14b71ff145fe8cdc2fa98c7f45">yyjson_mut_obj_iter_get_val</a>(key);</div>
<div class="line">    <span class="keywordflow">if</span> (your_key_is_unused(key)) {</div>
<div class="line">        <span class="comment">// you can remove current kv pair inside iteration</span></div>
<div class="line">        <a class="code hl_function" href="yyjson_8h.html#a6e891b4020dd6325d6eacb5e108da3c4">yyjson_mut_obj_iter_remove</a>(&amp;iter);</div>
<div class="line">    }</div>
<div class="line">}</div>
<div class="ttc" id="ayyjson_8h_html_a55f4228c2d65d497ad3cee8abe95c0be"><div class="ttname"><a href="yyjson_8h.html#a55f4228c2d65d497ad3cee8abe95c0be">yyjson_mut_obj_iter_next</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_iter_next(yyjson_mut_obj_iter *iter)</div><div class="ttdef"><b>Definition</b> yyjson.h:6804</div></div>
<div class="ttc" id="ayyjson_8h_html_a6e891b4020dd6325d6eacb5e108da3c4"><div class="ttname"><a href="yyjson_8h.html#a6e891b4020dd6325d6eacb5e108da3c4">yyjson_mut_obj_iter_remove</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_iter_remove(yyjson_mut_obj_iter *iter)</div><div class="ttdef"><b>Definition</b> yyjson.h:6821</div></div>
<div class="ttc" id="ayyjson_8h_html_aaa4bef14b71ff145fe8cdc2fa98c7f45"><div class="ttname"><a href="yyjson_8h.html#aaa4bef14b71ff145fe8cdc2fa98c7f45">yyjson_mut_obj_iter_get_val</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_iter_get_val(yyjson_mut_val *key)</div><div class="ttdef"><b>Definition</b> yyjson.h:6816</div></div>
<div class="ttc" id="ayyjson_8h_html_aedac207e6c2d5e031997e2b0df73db6a"><div class="ttname"><a href="yyjson_8h.html#aedac207e6c2d5e031997e2b0df73db6a">yyjson_mut_obj_iter_with</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_obj_iter yyjson_mut_obj_iter_with(yyjson_mut_val *obj)</div><div class="ttdef"><b>Definition</b> yyjson.h:6793</div></div>
<div class="ttc" id="ayyjson_8h_html_structyyjson__mut__obj__iter"><div class="ttname"><a href="yyjson_8h.html#structyyjson__mut__obj__iter">yyjson_mut_obj_iter</a></div><div class="ttdef"><b>Definition</b> yyjson.h:3537</div></div>
</div><!-- fragment --><p>Sample code 2 (mutable foreach macro): </p><div class="fragment"><div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *obj; <span class="comment">// the object to be traversed</span></div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">size_t</span> idx, max;</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *key, *val;</div>
<div class="line"><a class="code hl_define" href="yyjson_8h.html#a32884e21b899ea5869b12aec02083002">yyjson_obj_foreach</a>(obj, idx, max, key, val) {</div>
<div class="line">    your_func(key, val);</div>
<div class="line">}</div>
</div><!-- fragment --><hr  />
 <h1><a class="anchor" id="creating-json-document"></a>
Creating JSON Document</h1>
<p>The <code><a class="el" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a></code> and related APIs are used to build JSON documents. <br  />
</p>
<p>Please note that <code><a class="el" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a></code> uses a <b>memory pool</b> to hold all strings and values. The pool can only be created, grown, or freed in its entirety. Therefore, <code><a class="el" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a></code> is more suitable for write-once than mutation of an existing document.<br  />
</p>
<p>JSON objects and arrays are composed of linked lists, so each <code><a class="el" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a></code> can only be added to one object or array.</p>
<p>Sample code:</p>
<div class="fragment"><div class="line"><span class="comment">// Build this JSON:</span></div>
<div class="line"><span class="comment">//     {</span></div>
<div class="line"><span class="comment">//        &quot;page&quot;: 123,</span></div>
<div class="line"><span class="comment">//        &quot;names&quot;: [ &quot;Harry&quot;, &quot;Ron&quot;, &quot;Hermione&quot; ]</span></div>
<div class="line"><span class="comment">//     }</span></div>
<div class="line"> </div>
<div class="line"><span class="comment">// Create a mutable document.</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc = <a class="code hl_function" href="yyjson_8h.html#ae27cb375110302ec19f4376d7cab3c5b">yyjson_mut_doc_new</a>(NULL);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Create an object, the value&#39;s memory is held by doc.</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *root = <a class="code hl_function" href="yyjson_8h.html#a721dacf0e32ee6c7f18817aca806e9b2">yyjson_mut_obj</a>(doc);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Create key and value, add to the root object.</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *key = <a class="code hl_function" href="yyjson_8h.html#ae8d7e4c75adb1b9adb2246165491a4a3">yyjson_mut_str</a>(doc, <span class="stringliteral">&quot;page&quot;</span>);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *num = <a class="code hl_function" href="yyjson_8h.html#a92e202b3738250ffee612089bdec91eb">yyjson_mut_int</a>(doc, 123);</div>
<div class="line"><a class="code hl_function" href="yyjson_8h.html#ac0e1bcd9f449e4b1e62d25fb96830a62">yyjson_mut_obj_add</a>(root, key, num);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Create 3 string value, add to the array object.</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *names = <a class="code hl_function" href="yyjson_8h.html#aec0e874c4847338f3b61bf46257cb557">yyjson_mut_arr</a>(doc);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *name1 = <a class="code hl_function" href="yyjson_8h.html#ae8d7e4c75adb1b9adb2246165491a4a3">yyjson_mut_str</a>(doc, <span class="stringliteral">&quot;Harry&quot;</span>);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *name2 = <a class="code hl_function" href="yyjson_8h.html#ae8d7e4c75adb1b9adb2246165491a4a3">yyjson_mut_str</a>(doc, <span class="stringliteral">&quot;Ron&quot;</span>);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *name3 = <a class="code hl_function" href="yyjson_8h.html#ae8d7e4c75adb1b9adb2246165491a4a3">yyjson_mut_str</a>(doc, <span class="stringliteral">&quot;Hermione&quot;</span>);</div>
<div class="line"><a class="code hl_function" href="yyjson_8h.html#af089d7f9bfb1b4fadf46073a534379b0">yyjson_mut_arr_append</a>(names, name1);</div>
<div class="line"><a class="code hl_function" href="yyjson_8h.html#af089d7f9bfb1b4fadf46073a534379b0">yyjson_mut_arr_append</a>(names, name2);</div>
<div class="line"><a class="code hl_function" href="yyjson_8h.html#af089d7f9bfb1b4fadf46073a534379b0">yyjson_mut_arr_append</a>(names, name3);</div>
<div class="line"><a class="code hl_function" href="yyjson_8h.html#ac0e1bcd9f449e4b1e62d25fb96830a62">yyjson_mut_obj_add</a>(root, <a class="code hl_function" href="yyjson_8h.html#ae8d7e4c75adb1b9adb2246165491a4a3">yyjson_mut_str</a>(doc, <span class="stringliteral">&quot;names&quot;</span>), names);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// ❌ Wrong! the value is already added to another container.</span></div>
<div class="line"><a class="code hl_function" href="yyjson_8h.html#ac0e1bcd9f449e4b1e62d25fb96830a62">yyjson_mut_obj_add</a>(root, key, name1);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Set the document&#39;s root value.</span></div>
<div class="line"><a class="code hl_function" href="yyjson_8h.html#a8a9f7ea865526acb97ee4eff8d0bb79f">yyjson_mut_doc_set_root</a>(doc, root);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Write to JSON string</span></div>
<div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> *json = <a class="code hl_function" href="yyjson_8h.html#a881e2ee3f487385810829df8bc675f1f">yyjson_mut_write</a>(doc, 0, NULL);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Free the memory of doc and all values which is created from this doc.</span></div>
<div class="line"><a class="code hl_function" href="yyjson_8h.html#a7a5f504993031f912d06777b8a7b5aff">yyjson_mut_doc_free</a>(doc);</div>
<div class="ttc" id="ayyjson_8h_html_a721dacf0e32ee6c7f18817aca806e9b2"><div class="ttname"><a href="yyjson_8h.html#a721dacf0e32ee6c7f18817aca806e9b2">yyjson_mut_obj</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_obj(yyjson_mut_doc *doc)</div><div class="ttdef"><b>Definition</b> yyjson.h:6870</div></div>
<div class="ttc" id="ayyjson_8h_html_a7a5f504993031f912d06777b8a7b5aff"><div class="ttname"><a href="yyjson_8h.html#a7a5f504993031f912d06777b8a7b5aff">yyjson_mut_doc_free</a></div><div class="ttdeci">yyjson_api void yyjson_mut_doc_free(yyjson_mut_doc *doc)</div></div>
<div class="ttc" id="ayyjson_8h_html_a92e202b3738250ffee612089bdec91eb"><div class="ttname"><a href="yyjson_8h.html#a92e202b3738250ffee612089bdec91eb">yyjson_mut_int</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_int(yyjson_mut_doc *doc, int64_t num)</div><div class="ttdef"><b>Definition</b> yyjson.h:6035</div></div>
<div class="ttc" id="ayyjson_8h_html_ac0e1bcd9f449e4b1e62d25fb96830a62"><div class="ttname"><a href="yyjson_8h.html#ac0e1bcd9f449e4b1e62d25fb96830a62">yyjson_mut_obj_add</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_obj_add(yyjson_mut_val *obj, yyjson_mut_val *key, yyjson_mut_val *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:7024</div></div>
<div class="ttc" id="ayyjson_8h_html_af089d7f9bfb1b4fadf46073a534379b0"><div class="ttname"><a href="yyjson_8h.html#af089d7f9bfb1b4fadf46073a534379b0">yyjson_mut_arr_append</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_arr_append(yyjson_mut_val *arr, yyjson_mut_val *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:6405</div></div>
</div><!-- fragment --><h2><a class="anchor" id="mutable-document"></a>
Mutable Document</h2>
<p>The following functions are used to create, modify, copy, and destroy a JSON document.<br  />
</p>
<div class="fragment"><div class="line"><span class="comment">// Creates and returns a new mutable JSON document.</span></div>
<div class="line"><span class="comment">// Returns NULL on error (e.g. memory allocation failure).</span></div>
<div class="line"><span class="comment">// If `alc` is NULL, the default allocator will be used.</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *<a class="code hl_function" href="yyjson_8h.html#ae27cb375110302ec19f4376d7cab3c5b">yyjson_mut_doc_new</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__alc">yyjson_alc</a> *alc);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Delete the JSON document, free the memory of this doc</span></div>
<div class="line"><span class="comment">// and all values created from this doc</span></div>
<div class="line"><span class="keywordtype">void</span> <a class="code hl_function" href="yyjson_8h.html#a7a5f504993031f912d06777b8a7b5aff">yyjson_mut_doc_free</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Set the internal memory pool size (string length and value count).</span></div>
<div class="line"><span class="comment">// It can be used to reserve memory for the next string and value creation.</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#aec93f33123755af4dfa25c1335a44184">yyjson_mut_doc_set_str_pool_size</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keywordtype">size_t</span> len);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a9dd1f854542f298e963f0912a5a0e002">yyjson_mut_doc_set_val_pool_size</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keywordtype">size_t</span> count);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Get or set the root value of this JSON document.</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#aa33ac310f363ace5f4dda3697b2c0123">yyjson_mut_doc_get_root</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc);</div>
<div class="line"><span class="keywordtype">void</span> <a class="code hl_function" href="yyjson_8h.html#a8a9f7ea865526acb97ee4eff8d0bb79f">yyjson_mut_doc_set_root</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *root);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Copies and returns a new mutable document/value from input.</span></div>
<div class="line"><span class="comment">// Returns NULL on error (e.g. memory allocation failure).</span></div>
<div class="line"> </div>
<div class="line"><span class="comment">// doc -&gt; mut_doc</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *<a class="code hl_function" href="yyjson_8h.html#a083356ecb65e45453033285f3d836de9">yyjson_doc_mut_copy</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *doc, <span class="keyword">const</span> <a class="code hl_struct" href="yyjson_8h.html#structyyjson__alc">yyjson_alc</a> *alc);</div>
<div class="line"><span class="comment">// val -&gt; mut_val</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a04ff184b833fe2d6932309821e2b2e5a">yyjson_val_mut_copy</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc,  <a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val);</div>
<div class="line"><span class="comment">// mut_doc -&gt; mut_doc</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *<a class="code hl_function" href="yyjson_8h.html#a6ee1dc133fa773528286cd0b25300cb2">yyjson_mut_doc_mut_copy</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keyword">const</span> <a class="code hl_struct" href="yyjson_8h.html#structyyjson__alc">yyjson_alc</a> *alc);</div>
<div class="line"><span class="comment">// mut_val -&gt; mut_val</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a66761be40cfb010086ec798ddb44018f">yyjson_mut_val_mut_copy</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *val);</div>
<div class="line"><span class="comment">// mut_doc -&gt; doc</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *<a class="code hl_function" href="yyjson_8h.html#a797642b2f815a4f05db03ef87f08cc4f">yyjson_mut_doc_imut_copy</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__alc">yyjson_alc</a> *alc);</div>
<div class="line"><span class="comment">// mut_val -&gt; doc</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *<a class="code hl_function" href="yyjson_8h.html#a7a142af553e7831989593aee44f74e26">yyjson_mut_val_imut_copy</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *val, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__alc">yyjson_alc</a> *alc);</div>
<div class="ttc" id="ayyjson_8h_html_a66761be40cfb010086ec798ddb44018f"><div class="ttname"><a href="yyjson_8h.html#a66761be40cfb010086ec798ddb44018f">yyjson_mut_val_mut_copy</a></div><div class="ttdeci">yyjson_api yyjson_mut_val * yyjson_mut_val_mut_copy(yyjson_mut_doc *doc, yyjson_mut_val *val)</div></div>
<div class="ttc" id="ayyjson_8h_html_a6ee1dc133fa773528286cd0b25300cb2"><div class="ttname"><a href="yyjson_8h.html#a6ee1dc133fa773528286cd0b25300cb2">yyjson_mut_doc_mut_copy</a></div><div class="ttdeci">yyjson_api yyjson_mut_doc * yyjson_mut_doc_mut_copy(yyjson_mut_doc *doc, const yyjson_alc *alc)</div></div>
<div class="ttc" id="ayyjson_8h_html_a9dd1f854542f298e963f0912a5a0e002"><div class="ttname"><a href="yyjson_8h.html#a9dd1f854542f298e963f0912a5a0e002">yyjson_mut_doc_set_val_pool_size</a></div><div class="ttdeci">yyjson_api bool yyjson_mut_doc_set_val_pool_size(yyjson_mut_doc *doc, size_t count)</div></div>
<div class="ttc" id="ayyjson_8h_html_aa33ac310f363ace5f4dda3697b2c0123"><div class="ttname"><a href="yyjson_8h.html#aa33ac310f363ace5f4dda3697b2c0123">yyjson_mut_doc_get_root</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_doc_get_root(yyjson_mut_doc *doc)</div><div class="ttdef"><b>Definition</b> yyjson.h:5701</div></div>
<div class="ttc" id="ayyjson_8h_html_aec93f33123755af4dfa25c1335a44184"><div class="ttname"><a href="yyjson_8h.html#aec93f33123755af4dfa25c1335a44184">yyjson_mut_doc_set_str_pool_size</a></div><div class="ttdeci">yyjson_api bool yyjson_mut_doc_set_str_pool_size(yyjson_mut_doc *doc, size_t len)</div></div>
</div><!-- fragment --><h2><a class="anchor" id="json-value-creation"></a>
JSON Value Creation</h2>
<p>The following functions are used to create mutable JSON value, the value's memory is held by the document.<br  />
</p>
<div class="fragment"><div class="line"><span class="comment">// Creates and returns a new value, returns NULL on error.</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a73e0044fd0c511263cbf5cd869976475">yyjson_mut_null</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a032637dbdee5a6525420384daa097dff">yyjson_mut_true</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a184a7d8fa5b929ce01c7181712c34747">yyjson_mut_false</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a57afc80d0c89c0ae20d5ff183f3a8205">yyjson_mut_bool</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keywordtype">bool</span> val);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a893a09172b402af1bf520cf7347dfeab">yyjson_mut_uint</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, uint64_t num);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#acd434c1a97d275f97f743e47e228831a">yyjson_mut_sint</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, int64_t num);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a92e202b3738250ffee612089bdec91eb">yyjson_mut_int</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, int64_t num);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a3497c331c3a3746dab89e20a38c5daa0">yyjson_mut_float</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keywordtype">float</span> num);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a97fb1056954960e76be19e33dc5b6df0">yyjson_mut_double</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keywordtype">double</span> num);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a177181eee333314c7b40e2dc573fcdec">yyjson_mut_real</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keywordtype">double</span> num);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Creates a string value, the input string is NOT copied.</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#ae8d7e4c75adb1b9adb2246165491a4a3">yyjson_mut_str</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keyword">const</span> <span class="keywordtype">char</span> *str);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a13c39f37c6936907c266ba9c076dd741">yyjson_mut_strn</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keyword">const</span> <span class="keywordtype">char</span> *str, <span class="keywordtype">size_t</span> len);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Creates a string value, the input string is copied and held by the document.</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a95300bcf1cdb52d296e39aa1a4650741">yyjson_mut_strcpy</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keyword">const</span> <span class="keywordtype">char</span> *str);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a1588bdc6f4125e5c6d1daf6b240f6ff8">yyjson_mut_strncpy</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keyword">const</span> <span class="keywordtype">char</span> *str, <span class="keywordtype">size_t</span> len);</div>
<div class="ttc" id="ayyjson_8h_html_a032637dbdee5a6525420384daa097dff"><div class="ttname"><a href="yyjson_8h.html#a032637dbdee5a6525420384daa097dff">yyjson_mut_true</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_true(yyjson_mut_doc *doc)</div><div class="ttdef"><b>Definition</b> yyjson.h:6012</div></div>
<div class="ttc" id="ayyjson_8h_html_a177181eee333314c7b40e2dc573fcdec"><div class="ttname"><a href="yyjson_8h.html#a177181eee333314c7b40e2dc573fcdec">yyjson_mut_real</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_real(yyjson_mut_doc *doc, double num)</div><div class="ttdef"><b>Definition</b> yyjson.h:6050</div></div>
<div class="ttc" id="ayyjson_8h_html_a184a7d8fa5b929ce01c7181712c34747"><div class="ttname"><a href="yyjson_8h.html#a184a7d8fa5b929ce01c7181712c34747">yyjson_mut_false</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_false(yyjson_mut_doc *doc)</div><div class="ttdef"><b>Definition</b> yyjson.h:6016</div></div>
<div class="ttc" id="ayyjson_8h_html_a3497c331c3a3746dab89e20a38c5daa0"><div class="ttname"><a href="yyjson_8h.html#a3497c331c3a3746dab89e20a38c5daa0">yyjson_mut_float</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_float(yyjson_mut_doc *doc, float num)</div><div class="ttdef"><b>Definition</b> yyjson.h:6040</div></div>
<div class="ttc" id="ayyjson_8h_html_a57afc80d0c89c0ae20d5ff183f3a8205"><div class="ttname"><a href="yyjson_8h.html#a57afc80d0c89c0ae20d5ff183f3a8205">yyjson_mut_bool</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_bool(yyjson_mut_doc *doc, bool val)</div><div class="ttdef"><b>Definition</b> yyjson.h:6020</div></div>
<div class="ttc" id="ayyjson_8h_html_a73e0044fd0c511263cbf5cd869976475"><div class="ttname"><a href="yyjson_8h.html#a73e0044fd0c511263cbf5cd869976475">yyjson_mut_null</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_null(yyjson_mut_doc *doc)</div><div class="ttdef"><b>Definition</b> yyjson.h:6008</div></div>
<div class="ttc" id="ayyjson_8h_html_a893a09172b402af1bf520cf7347dfeab"><div class="ttname"><a href="yyjson_8h.html#a893a09172b402af1bf520cf7347dfeab">yyjson_mut_uint</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_uint(yyjson_mut_doc *doc, uint64_t num)</div><div class="ttdef"><b>Definition</b> yyjson.h:6025</div></div>
<div class="ttc" id="ayyjson_8h_html_a97fb1056954960e76be19e33dc5b6df0"><div class="ttname"><a href="yyjson_8h.html#a97fb1056954960e76be19e33dc5b6df0">yyjson_mut_double</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_double(yyjson_mut_doc *doc, double num)</div><div class="ttdef"><b>Definition</b> yyjson.h:6045</div></div>
<div class="ttc" id="ayyjson_8h_html_acd434c1a97d275f97f743e47e228831a"><div class="ttname"><a href="yyjson_8h.html#acd434c1a97d275f97f743e47e228831a">yyjson_mut_sint</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_sint(yyjson_mut_doc *doc, int64_t num)</div><div class="ttdef"><b>Definition</b> yyjson.h:6030</div></div>
</div><!-- fragment --><h2><a class="anchor" id="json-array-creation"></a>
JSON Array Creation</h2>
<p>The following functions are used to create mutable JSON array.<br  />
</p>
<div class="fragment"><div class="line"><span class="comment">// Creates and returns an empty mutable array, returns NULL on error.</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#aec0e874c4847338f3b61bf46257cb557">yyjson_mut_arr</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Creates and returns a mutable array with c array.</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#afd2b114767b989006259409c6955bb37">yyjson_mut_arr_with_bool</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keywordtype">bool</span> *vals, <span class="keywordtype">size_t</span> count);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a05771fb3cd9c9d2f854dc9528feac58a">yyjson_mut_arr_with_sint</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, int64_t *vals, <span class="keywordtype">size_t</span> count);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#ab2237deb1190a0333a88d571a8adcb0c">yyjson_mut_arr_with_uint</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, uint64_t *vals, <span class="keywordtype">size_t</span> count);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a7173b66e47ee6fad38b11651d20e7ddf">yyjson_mut_arr_with_real</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keywordtype">double</span> *vals, <span class="keywordtype">size_t</span> count);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#ab9c7f452ed21a9800501c25e715f35f7">yyjson_mut_arr_with_sint8</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, int8_t *vals, <span class="keywordtype">size_t</span> count);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a72bd3b0467273c40dbe376bc7c0a8f06">yyjson_mut_arr_with_sint16</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, int16_t *vals, <span class="keywordtype">size_t</span> count);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a54bfa0c027fb21e9e5c33a9f4ecbe0f5">yyjson_mut_arr_with_sint32</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, int32_t *vals, <span class="keywordtype">size_t</span> count);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a37d0c7987b2958550076586ca36082fd">yyjson_mut_arr_with_sint64</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, int64_t *vals, <span class="keywordtype">size_t</span> count);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a2ae7e73e8a1431554d621059b06222e6">yyjson_mut_arr_with_uint8</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, uint8_t *vals, <span class="keywordtype">size_t</span> count);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a85f4bcdc777cde51a40359ac9e38c98b">yyjson_mut_arr_with_uint16</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, uint16_t *vals, <span class="keywordtype">size_t</span> count);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#ac24336d6f29b5b6c09f513373b6fc83e">yyjson_mut_arr_with_uint32</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, uint32_t *vals, <span class="keywordtype">size_t</span> count);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#aae70fe76dfae0e8aa93d0226ec8510d9">yyjson_mut_arr_with_uint64</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, uint64_t *vals, <span class="keywordtype">size_t</span> count);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a50039175677ae5fdd51f1c6942fa3d3d">yyjson_mut_arr_with_float</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keywordtype">float</span> *vals, <span class="keywordtype">size_t</span> count);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#ac81702a782ecfeb9874ce43706ecf02e">yyjson_mut_arr_with_double</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keywordtype">double</span> *vals, <span class="keywordtype">size_t</span> count);</div>
<div class="line"><span class="comment">// sample code:</span></div>
<div class="line"><span class="keywordtype">int</span> vals[3] = {-1, 0, 1};</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *arr = <a class="code hl_function" href="yyjson_8h.html#a54bfa0c027fb21e9e5c33a9f4ecbe0f5">yyjson_mut_arr_with_sint32</a>(doc, vals, 3);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Creates and returns a mutable array with strings,</span></div>
<div class="line"><span class="comment">// the strings should be encoded as UTF-8.</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#af7da1562cde867338bc69395c2aeb0ad">yyjson_mut_arr_with_str</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keyword">const</span> <span class="keywordtype">char</span> **vals, <span class="keywordtype">size_t</span> count);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a419008c4a6f2dc4221211b0d7770109a">yyjson_mut_arr_with_strn</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keyword">const</span> <span class="keywordtype">char</span> **vals, <span class="keyword">const</span> <span class="keywordtype">size_t</span> *lens, <span class="keywordtype">size_t</span> count);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a90c3e1c55dcf04a7879abed9a57cb278">yyjson_mut_arr_with_strcpy</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keyword">const</span> <span class="keywordtype">char</span> **vals, <span class="keywordtype">size_t</span> count);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#ad8c68a8cec010d2d5f8942eb1136afde">yyjson_mut_arr_with_strncpy</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keyword">const</span> <span class="keywordtype">char</span> **vals, <span class="keyword">const</span> <span class="keywordtype">size_t</span> *lens, <span class="keywordtype">size_t</span> count);</div>
<div class="line"><span class="comment">// sample code:</span></div>
<div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> strs[3] = {<span class="stringliteral">&quot;Jan&quot;</span>, <span class="stringliteral">&quot;Feb&quot;</span>, <span class="stringliteral">&quot;Mar&quot;</span>};</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *arr = <a class="code hl_function" href="yyjson_8h.html#af7da1562cde867338bc69395c2aeb0ad">yyjson_mut_arr_with_str</a>(doc, strs, 3);</div>
<div class="ttc" id="ayyjson_8h_html_a05771fb3cd9c9d2f854dc9528feac58a"><div class="ttname"><a href="yyjson_8h.html#a05771fb3cd9c9d2f854dc9528feac58a">yyjson_mut_arr_with_sint</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_sint(yyjson_mut_doc *doc, const int64_t *vals, size_t count)</div><div class="ttdef"><b>Definition</b> yyjson.h:6233</div></div>
<div class="ttc" id="ayyjson_8h_html_a2ae7e73e8a1431554d621059b06222e6"><div class="ttname"><a href="yyjson_8h.html#a2ae7e73e8a1431554d621059b06222e6">yyjson_mut_arr_with_uint8</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_uint8(yyjson_mut_doc *doc, const uint8_t *vals, size_t count)</div><div class="ttdef"><b>Definition</b> yyjson.h:6278</div></div>
<div class="ttc" id="ayyjson_8h_html_a37d0c7987b2958550076586ca36082fd"><div class="ttname"><a href="yyjson_8h.html#a37d0c7987b2958550076586ca36082fd">yyjson_mut_arr_with_sint64</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_sint64(yyjson_mut_doc *doc, const int64_t *vals, size_t count)</div><div class="ttdef"><b>Definition</b> yyjson.h:6271</div></div>
<div class="ttc" id="ayyjson_8h_html_a419008c4a6f2dc4221211b0d7770109a"><div class="ttname"><a href="yyjson_8h.html#a419008c4a6f2dc4221211b0d7770109a">yyjson_mut_arr_with_strn</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_strn(yyjson_mut_doc *doc, const char **vals, const size_t *lens, size_t count)</div><div class="ttdef"><b>Definition</b> yyjson.h:6328</div></div>
<div class="ttc" id="ayyjson_8h_html_a50039175677ae5fdd51f1c6942fa3d3d"><div class="ttname"><a href="yyjson_8h.html#a50039175677ae5fdd51f1c6942fa3d3d">yyjson_mut_arr_with_float</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_float(yyjson_mut_doc *doc, const float *vals, size_t count)</div><div class="ttdef"><b>Definition</b> yyjson.h:6306</div></div>
<div class="ttc" id="ayyjson_8h_html_a54bfa0c027fb21e9e5c33a9f4ecbe0f5"><div class="ttname"><a href="yyjson_8h.html#a54bfa0c027fb21e9e5c33a9f4ecbe0f5">yyjson_mut_arr_with_sint32</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_sint32(yyjson_mut_doc *doc, const int32_t *vals, size_t count)</div><div class="ttdef"><b>Definition</b> yyjson.h:6264</div></div>
<div class="ttc" id="ayyjson_8h_html_a7173b66e47ee6fad38b11651d20e7ddf"><div class="ttname"><a href="yyjson_8h.html#a7173b66e47ee6fad38b11651d20e7ddf">yyjson_mut_arr_with_real</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_real(yyjson_mut_doc *doc, const double *vals, size_t count)</div><div class="ttdef"><b>Definition</b> yyjson.h:6243</div></div>
<div class="ttc" id="ayyjson_8h_html_a72bd3b0467273c40dbe376bc7c0a8f06"><div class="ttname"><a href="yyjson_8h.html#a72bd3b0467273c40dbe376bc7c0a8f06">yyjson_mut_arr_with_sint16</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_sint16(yyjson_mut_doc *doc, const int16_t *vals, size_t count)</div><div class="ttdef"><b>Definition</b> yyjson.h:6257</div></div>
<div class="ttc" id="ayyjson_8h_html_a85f4bcdc777cde51a40359ac9e38c98b"><div class="ttname"><a href="yyjson_8h.html#a85f4bcdc777cde51a40359ac9e38c98b">yyjson_mut_arr_with_uint16</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_uint16(yyjson_mut_doc *doc, const uint16_t *vals, size_t count)</div><div class="ttdef"><b>Definition</b> yyjson.h:6285</div></div>
<div class="ttc" id="ayyjson_8h_html_a90c3e1c55dcf04a7879abed9a57cb278"><div class="ttname"><a href="yyjson_8h.html#a90c3e1c55dcf04a7879abed9a57cb278">yyjson_mut_arr_with_strcpy</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_strcpy(yyjson_mut_doc *doc, const char **vals, size_t count)</div><div class="ttdef"><b>Definition</b> yyjson.h:6337</div></div>
<div class="ttc" id="ayyjson_8h_html_aae70fe76dfae0e8aa93d0226ec8510d9"><div class="ttname"><a href="yyjson_8h.html#aae70fe76dfae0e8aa93d0226ec8510d9">yyjson_mut_arr_with_uint64</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_uint64(yyjson_mut_doc *doc, const uint64_t *vals, size_t count)</div><div class="ttdef"><b>Definition</b> yyjson.h:6299</div></div>
<div class="ttc" id="ayyjson_8h_html_ab2237deb1190a0333a88d571a8adcb0c"><div class="ttname"><a href="yyjson_8h.html#ab2237deb1190a0333a88d571a8adcb0c">yyjson_mut_arr_with_uint</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_uint(yyjson_mut_doc *doc, const uint64_t *vals, size_t count)</div><div class="ttdef"><b>Definition</b> yyjson.h:6238</div></div>
<div class="ttc" id="ayyjson_8h_html_ab9c7f452ed21a9800501c25e715f35f7"><div class="ttname"><a href="yyjson_8h.html#ab9c7f452ed21a9800501c25e715f35f7">yyjson_mut_arr_with_sint8</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_sint8(yyjson_mut_doc *doc, const int8_t *vals, size_t count)</div><div class="ttdef"><b>Definition</b> yyjson.h:6250</div></div>
<div class="ttc" id="ayyjson_8h_html_ac24336d6f29b5b6c09f513373b6fc83e"><div class="ttname"><a href="yyjson_8h.html#ac24336d6f29b5b6c09f513373b6fc83e">yyjson_mut_arr_with_uint32</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_uint32(yyjson_mut_doc *doc, const uint32_t *vals, size_t count)</div><div class="ttdef"><b>Definition</b> yyjson.h:6292</div></div>
<div class="ttc" id="ayyjson_8h_html_ac81702a782ecfeb9874ce43706ecf02e"><div class="ttname"><a href="yyjson_8h.html#ac81702a782ecfeb9874ce43706ecf02e">yyjson_mut_arr_with_double</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_double(yyjson_mut_doc *doc, const double *vals, size_t count)</div><div class="ttdef"><b>Definition</b> yyjson.h:6313</div></div>
<div class="ttc" id="ayyjson_8h_html_ad8c68a8cec010d2d5f8942eb1136afde"><div class="ttname"><a href="yyjson_8h.html#ad8c68a8cec010d2d5f8942eb1136afde">yyjson_mut_arr_with_strncpy</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_strncpy(yyjson_mut_doc *doc, const char **vals, const size_t *lens, size_t count)</div><div class="ttdef"><b>Definition</b> yyjson.h:6351</div></div>
<div class="ttc" id="ayyjson_8h_html_af7da1562cde867338bc69395c2aeb0ad"><div class="ttname"><a href="yyjson_8h.html#af7da1562cde867338bc69395c2aeb0ad">yyjson_mut_arr_with_str</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_str(yyjson_mut_doc *doc, const char **vals, size_t count)</div><div class="ttdef"><b>Definition</b> yyjson.h:6320</div></div>
<div class="ttc" id="ayyjson_8h_html_afd2b114767b989006259409c6955bb37"><div class="ttname"><a href="yyjson_8h.html#afd2b114767b989006259409c6955bb37">yyjson_mut_arr_with_bool</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_bool(yyjson_mut_doc *doc, const bool *vals, size_t count)</div><div class="ttdef"><b>Definition</b> yyjson.h:6226</div></div>
</div><!-- fragment --><h2><a class="anchor" id="json-array-modification"></a>
JSON Array Modification</h2>
<p>The following functions are used to modify the contents of a JSON array.<br  />
</p>
<div class="fragment"><div class="line"><span class="comment">// Inserts a value into an array at a given index.</span></div>
<div class="line"><span class="comment">// Returns false on error (e.g. out of bounds).</span></div>
<div class="line"><span class="comment">// Note that this function takes a linear search time.</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#ae0898f45c9fca1d7d6bdd35b3488a10f">yyjson_mut_arr_insert</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *arr, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *val, <span class="keywordtype">size_t</span> idx);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Inserts a val at the end of the array, returns false on error.</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#af089d7f9bfb1b4fadf46073a534379b0">yyjson_mut_arr_append</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *arr, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *val);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Inserts a val at the head of the array, returns false on error.</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a1557f6dca4e03380449cb9b5f043f699">yyjson_mut_arr_prepend</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *arr, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *val);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Replaces a value at index and returns old value, returns NULL on error.</span></div>
<div class="line"><span class="comment">// Note that this function takes a linear search time.</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a33704c7475fcdbc8ce7504e9b9756b16">yyjson_mut_arr_replace</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *arr, <span class="keywordtype">size_t</span> idx, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *val);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Removes and returns a value at index, returns NULL on error.</span></div>
<div class="line"><span class="comment">// Note that this function takes a linear search time.</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a26d9cd39957b06085492ec7050850a19">yyjson_mut_arr_remove</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *arr, <span class="keywordtype">size_t</span> idx);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Removes and returns the first value in this array, returns NULL on error.</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#af7484aeed9b789103efb985f2f42ab46">yyjson_mut_arr_remove_first</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *arr);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Removes and returns the last value in this array, returns NULL on error.</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a923bc9e3c4af69b5bdb5361a9f0a4ba5">yyjson_mut_arr_remove_last</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *arr);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Removes all values within a specified range in the array.</span></div>
<div class="line"><span class="comment">// Note that this function takes a linear search time.</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#ab96f33fef20cadcb9bb045c60749b516">yyjson_mut_arr_remove_range</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *arr, <span class="keywordtype">size_t</span> idx, <span class="keywordtype">size_t</span> len);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Removes all values in this array.</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a274fc7be14bed93794e3e720927f7bc5">yyjson_mut_arr_clear</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *arr);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Convenience API:</span></div>
<div class="line"><span class="comment">// Adds a value at the end of this array, returns false on error.</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#ab361240999d684579904a9aa3af5004f">yyjson_mut_arr_add_val</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *arr, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *val);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#afb1e130c69db1f54e924e82c3d6377c9">yyjson_mut_arr_add_null</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *arr);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a125859d255ca67ed339fbf3d05539c94">yyjson_mut_arr_add_true</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *arr);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a930a47cf837316e3758e38057178edac">yyjson_mut_arr_add_false</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *arr);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a5c7fae9804b126005f99c67f3c703ad5">yyjson_mut_arr_add_bool</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *arr, <span class="keywordtype">bool</span> val);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a6efba736a610baa629bf2a0b0a41d4a9">yyjson_mut_arr_add_uint</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *arr, uint64_t num);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#ab459a079674a115123c353441dacda22">yyjson_mut_arr_add_sint</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *arr, int64_t num);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#ad20aad460c6d7c62f7c371ca5be54667">yyjson_mut_arr_add_int</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *arr, int64_t num);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#ab07c81d726e44806b918481becf7f6d3">yyjson_mut_arr_add_float</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *arr, <span class="keywordtype">float</span> num);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a39283533d6fee8d33eb0e3b818ce8fee">yyjson_mut_arr_add_double</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *arr, <span class="keywordtype">double</span> num);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#aa47704ca9b08cdd7b8b151ec67c4afd6">yyjson_mut_arr_add_real</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *arr, <span class="keywordtype">double</span> num);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a09acbadaf1d791167a277ed35540577b">yyjson_mut_arr_add_str</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *arr, <span class="keyword">const</span> <span class="keywordtype">char</span> *str);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a97b82f92bd96415090ce9803b9757bf9">yyjson_mut_arr_add_strn</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *arr, <span class="keyword">const</span> <span class="keywordtype">char</span> *str, <span class="keywordtype">size_t</span> len);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a2877858de77e7765ef44d8659eb7fcd3">yyjson_mut_arr_add_strcpy</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *arr, <span class="keyword">const</span> <span class="keywordtype">char</span> *str);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a158fecc9fb751aeb56472844321bdfab">yyjson_mut_arr_add_strncpy</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *arr, <span class="keyword">const</span> <span class="keywordtype">char</span> *str, <span class="keywordtype">size_t</span> len);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Convenience API:</span></div>
<div class="line"><span class="comment">// Creates and adds a new array at the end of the array.</span></div>
<div class="line"><span class="comment">// Returns the new array, or NULL on error.</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a8e0dfe2ac2a53faadf137d159162d193">yyjson_mut_arr_add_arr</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *arr);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Convenience API:</span></div>
<div class="line"><span class="comment">// Creates and adds a new object at the end of the array.</span></div>
<div class="line"><span class="comment">// Returns the new object, or NULL on error.</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#acd2884309c99b42f916fffd50c018c59">yyjson_mut_arr_add_obj</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *arr);</div>
<div class="ttc" id="ayyjson_8h_html_a09acbadaf1d791167a277ed35540577b"><div class="ttname"><a href="yyjson_8h.html#a09acbadaf1d791167a277ed35540577b">yyjson_mut_arr_add_str</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_arr_add_str(yyjson_mut_doc *doc, yyjson_mut_val *arr, const char *str)</div><div class="ttdef"><b>Definition</b> yyjson.h:6686</div></div>
<div class="ttc" id="ayyjson_8h_html_a125859d255ca67ed339fbf3d05539c94"><div class="ttname"><a href="yyjson_8h.html#a125859d255ca67ed339fbf3d05539c94">yyjson_mut_arr_add_true</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_arr_add_true(yyjson_mut_doc *doc, yyjson_mut_val *arr)</div><div class="ttdef"><b>Definition</b> yyjson.h:6598</div></div>
<div class="ttc" id="ayyjson_8h_html_a1557f6dca4e03380449cb9b5f043f699"><div class="ttname"><a href="yyjson_8h.html#a1557f6dca4e03380449cb9b5f043f699">yyjson_mut_arr_prepend</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_arr_prepend(yyjson_mut_val *arr, yyjson_mut_val *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:6424</div></div>
<div class="ttc" id="ayyjson_8h_html_a158fecc9fb751aeb56472844321bdfab"><div class="ttname"><a href="yyjson_8h.html#a158fecc9fb751aeb56472844321bdfab">yyjson_mut_arr_add_strncpy</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_arr_add_strncpy(yyjson_mut_doc *doc, yyjson_mut_val *arr, const char *str, size_t len)</div><div class="ttdef"><b>Definition</b> yyjson.h:6716</div></div>
<div class="ttc" id="ayyjson_8h_html_a26d9cd39957b06085492ec7050850a19"><div class="ttname"><a href="yyjson_8h.html#a26d9cd39957b06085492ec7050850a19">yyjson_mut_arr_remove</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_remove(yyjson_mut_val *arr, size_t idx)</div><div class="ttdef"><b>Definition</b> yyjson.h:6471</div></div>
<div class="ttc" id="ayyjson_8h_html_a274fc7be14bed93794e3e720927f7bc5"><div class="ttname"><a href="yyjson_8h.html#a274fc7be14bed93794e3e720927f7bc5">yyjson_mut_arr_clear</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_arr_clear(yyjson_mut_val *arr)</div><div class="ttdef"><b>Definition</b> yyjson.h:6558</div></div>
<div class="ttc" id="ayyjson_8h_html_a2877858de77e7765ef44d8659eb7fcd3"><div class="ttname"><a href="yyjson_8h.html#a2877858de77e7765ef44d8659eb7fcd3">yyjson_mut_arr_add_strcpy</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_arr_add_strcpy(yyjson_mut_doc *doc, yyjson_mut_val *arr, const char *str)</div><div class="ttdef"><b>Definition</b> yyjson.h:6706</div></div>
<div class="ttc" id="ayyjson_8h_html_a33704c7475fcdbc8ce7504e9b9756b16"><div class="ttname"><a href="yyjson_8h.html#a33704c7475fcdbc8ce7504e9b9756b16">yyjson_mut_arr_replace</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_replace(yyjson_mut_val *arr, size_t idx, yyjson_mut_val *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:6443</div></div>
<div class="ttc" id="ayyjson_8h_html_a39283533d6fee8d33eb0e3b818ce8fee"><div class="ttname"><a href="yyjson_8h.html#a39283533d6fee8d33eb0e3b818ce8fee">yyjson_mut_arr_add_double</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_arr_add_double(yyjson_mut_doc *doc, yyjson_mut_val *arr, double num)</div><div class="ttdef"><b>Definition</b> yyjson.h:6666</div></div>
<div class="ttc" id="ayyjson_8h_html_a5c7fae9804b126005f99c67f3c703ad5"><div class="ttname"><a href="yyjson_8h.html#a5c7fae9804b126005f99c67f3c703ad5">yyjson_mut_arr_add_bool</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_arr_add_bool(yyjson_mut_doc *doc, yyjson_mut_val *arr, bool val)</div><div class="ttdef"><b>Definition</b> yyjson.h:6616</div></div>
<div class="ttc" id="ayyjson_8h_html_a6efba736a610baa629bf2a0b0a41d4a9"><div class="ttname"><a href="yyjson_8h.html#a6efba736a610baa629bf2a0b0a41d4a9">yyjson_mut_arr_add_uint</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_arr_add_uint(yyjson_mut_doc *doc, yyjson_mut_val *arr, uint64_t num)</div><div class="ttdef"><b>Definition</b> yyjson.h:6626</div></div>
<div class="ttc" id="ayyjson_8h_html_a8e0dfe2ac2a53faadf137d159162d193"><div class="ttname"><a href="yyjson_8h.html#a8e0dfe2ac2a53faadf137d159162d193">yyjson_mut_arr_add_arr</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_add_arr(yyjson_mut_doc *doc, yyjson_mut_val *arr)</div><div class="ttdef"><b>Definition</b> yyjson.h:6726</div></div>
<div class="ttc" id="ayyjson_8h_html_a923bc9e3c4af69b5bdb5361a9f0a4ba5"><div class="ttname"><a href="yyjson_8h.html#a923bc9e3c4af69b5bdb5361a9f0a4ba5">yyjson_mut_arr_remove_last</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_remove_last(yyjson_mut_val *arr)</div><div class="ttdef"><b>Definition</b> yyjson.h:6514</div></div>
<div class="ttc" id="ayyjson_8h_html_a930a47cf837316e3758e38057178edac"><div class="ttname"><a href="yyjson_8h.html#a930a47cf837316e3758e38057178edac">yyjson_mut_arr_add_false</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_arr_add_false(yyjson_mut_doc *doc, yyjson_mut_val *arr)</div><div class="ttdef"><b>Definition</b> yyjson.h:6607</div></div>
<div class="ttc" id="ayyjson_8h_html_a97b82f92bd96415090ce9803b9757bf9"><div class="ttname"><a href="yyjson_8h.html#a97b82f92bd96415090ce9803b9757bf9">yyjson_mut_arr_add_strn</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_arr_add_strn(yyjson_mut_doc *doc, yyjson_mut_val *arr, const char *str, size_t len)</div><div class="ttdef"><b>Definition</b> yyjson.h:6696</div></div>
<div class="ttc" id="ayyjson_8h_html_aa47704ca9b08cdd7b8b151ec67c4afd6"><div class="ttname"><a href="yyjson_8h.html#aa47704ca9b08cdd7b8b151ec67c4afd6">yyjson_mut_arr_add_real</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_arr_add_real(yyjson_mut_doc *doc, yyjson_mut_val *arr, double num)</div><div class="ttdef"><b>Definition</b> yyjson.h:6676</div></div>
<div class="ttc" id="ayyjson_8h_html_ab07c81d726e44806b918481becf7f6d3"><div class="ttname"><a href="yyjson_8h.html#ab07c81d726e44806b918481becf7f6d3">yyjson_mut_arr_add_float</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_arr_add_float(yyjson_mut_doc *doc, yyjson_mut_val *arr, float num)</div><div class="ttdef"><b>Definition</b> yyjson.h:6656</div></div>
<div class="ttc" id="ayyjson_8h_html_ab361240999d684579904a9aa3af5004f"><div class="ttname"><a href="yyjson_8h.html#ab361240999d684579904a9aa3af5004f">yyjson_mut_arr_add_val</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_arr_add_val(yyjson_mut_val *arr, yyjson_mut_val *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:6584</div></div>
<div class="ttc" id="ayyjson_8h_html_ab459a079674a115123c353441dacda22"><div class="ttname"><a href="yyjson_8h.html#ab459a079674a115123c353441dacda22">yyjson_mut_arr_add_sint</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_arr_add_sint(yyjson_mut_doc *doc, yyjson_mut_val *arr, int64_t num)</div><div class="ttdef"><b>Definition</b> yyjson.h:6636</div></div>
<div class="ttc" id="ayyjson_8h_html_ab96f33fef20cadcb9bb045c60749b516"><div class="ttname"><a href="yyjson_8h.html#ab96f33fef20cadcb9bb045c60749b516">yyjson_mut_arr_remove_range</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_arr_remove_range(yyjson_mut_val *arr, size_t idx, size_t len)</div><div class="ttdef"><b>Definition</b> yyjson.h:6536</div></div>
<div class="ttc" id="ayyjson_8h_html_acd2884309c99b42f916fffd50c018c59"><div class="ttname"><a href="yyjson_8h.html#acd2884309c99b42f916fffd50c018c59">yyjson_mut_arr_add_obj</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_add_obj(yyjson_mut_doc *doc, yyjson_mut_val *arr)</div><div class="ttdef"><b>Definition</b> yyjson.h:6735</div></div>
<div class="ttc" id="ayyjson_8h_html_ae0898f45c9fca1d7d6bdd35b3488a10f"><div class="ttname"><a href="yyjson_8h.html#ae0898f45c9fca1d7d6bdd35b3488a10f">yyjson_mut_arr_insert</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_arr_insert(yyjson_mut_val *arr, yyjson_mut_val *val, size_t idx)</div><div class="ttdef"><b>Definition</b> yyjson.h:6374</div></div>
<div class="ttc" id="ayyjson_8h_html_af7484aeed9b789103efb985f2f42ab46"><div class="ttname"><a href="yyjson_8h.html#af7484aeed9b789103efb985f2f42ab46">yyjson_mut_arr_remove_first</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_remove_first(yyjson_mut_val *arr)</div><div class="ttdef"><b>Definition</b> yyjson.h:6495</div></div>
<div class="ttc" id="ayyjson_8h_html_afb1e130c69db1f54e924e82c3d6377c9"><div class="ttname"><a href="yyjson_8h.html#afb1e130c69db1f54e924e82c3d6377c9">yyjson_mut_arr_add_null</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_arr_add_null(yyjson_mut_doc *doc, yyjson_mut_val *arr)</div><div class="ttdef"><b>Definition</b> yyjson.h:6589</div></div>
</div><!-- fragment --><h2><a class="anchor" id="json-object-creation"></a>
JSON Object Creation</h2>
<p>The following functions are used to create mutable JSON object.<br  />
</p>
<div class="fragment"><div class="line"><span class="comment">// Creates and returns a mutable object, returns NULL on error.</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a721dacf0e32ee6c7f18817aca806e9b2">yyjson_mut_obj</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Creates and returns a mutable object with keys and values,</span></div>
<div class="line"><span class="comment">// returns NULL on error. The keys and values are NOT copied.</span></div>
<div class="line"><span class="comment">// The strings should be encoded as UTF-8 with null-terminator.</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a49cfc79051b729689f4f08592b284cc9">yyjson_mut_obj_with_str</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc,</div>
<div class="line">                                        <span class="keyword">const</span> <span class="keywordtype">char</span> **keys,</div>
<div class="line">                                        <span class="keyword">const</span> <span class="keywordtype">char</span> **vals,</div>
<div class="line">                                        <span class="keywordtype">size_t</span> count);</div>
<div class="line"><span class="comment">// sample code:</span></div>
<div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> keys[] = {<span class="stringliteral">&quot;name&quot;</span>, <span class="stringliteral">&quot;type&quot;</span>, <span class="stringliteral">&quot;id&quot;</span>};</div>
<div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> *vals[] = {<span class="stringliteral">&quot;Harry&quot;</span>, <span class="stringliteral">&quot;student&quot;</span>, <span class="stringliteral">&quot;123456&quot;</span>};</div>
<div class="line"><a class="code hl_function" href="yyjson_8h.html#a49cfc79051b729689f4f08592b284cc9">yyjson_mut_obj_with_str</a>(doc, keys, vals, 3);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Creates and returns a mutable object with key-value pairs,</span></div>
<div class="line"><span class="comment">// returns NULL on error. The keys and values are NOT copied.</span></div>
<div class="line"><span class="comment">// The strings should be encoded as UTF-8 with null-terminator.</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#afc2749d9ed694b6d0a4f5c14da19c7d4">yyjson_mut_obj_with_kv</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc,</div>
<div class="line">                                       <span class="keyword">const</span> <span class="keywordtype">char</span> **kv_pairs,</div>
<div class="line">                                       <span class="keywordtype">size_t</span> pair_count);</div>
<div class="line"><span class="comment">// sample code:</span></div>
<div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> *pairs[] = {<span class="stringliteral">&quot;name&quot;</span>, <span class="stringliteral">&quot;Harry&quot;</span>, <span class="stringliteral">&quot;type&quot;</span>, <span class="stringliteral">&quot;student&quot;</span>, <span class="stringliteral">&quot;id&quot;</span>, <span class="stringliteral">&quot;123456&quot;</span>};</div>
<div class="line"><a class="code hl_function" href="yyjson_8h.html#afc2749d9ed694b6d0a4f5c14da19c7d4">yyjson_mut_obj_with_kv</a>(doc, pairs, 3);</div>
<div class="ttc" id="ayyjson_8h_html_a49cfc79051b729689f4f08592b284cc9"><div class="ttname"><a href="yyjson_8h.html#a49cfc79051b729689f4f08592b284cc9">yyjson_mut_obj_with_str</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_with_str(yyjson_mut_doc *doc, const char **keys, const char **vals, size_t count)</div><div class="ttdef"><b>Definition</b> yyjson.h:6881</div></div>
<div class="ttc" id="ayyjson_8h_html_afc2749d9ed694b6d0a4f5c14da19c7d4"><div class="ttname"><a href="yyjson_8h.html#afc2749d9ed694b6d0a4f5c14da19c7d4">yyjson_mut_obj_with_kv</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_with_kv(yyjson_mut_doc *doc, const char **kv_pairs, size_t pair_count)</div><div class="ttdef"><b>Definition</b> yyjson.h:6912</div></div>
</div><!-- fragment --><h2><a class="anchor" id="json-object-modification"></a>
JSON Object Modification</h2>
<p>The following functions are used to modify the contents of a JSON object.<br  />
</p>
<div class="fragment"><div class="line"><span class="comment">// Adds a key-value pair at the end of the object. </span></div>
<div class="line"><span class="comment">// The key must be a string value.</span></div>
<div class="line"><span class="comment">// This function allows duplicated key in one object.</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#ac0e1bcd9f449e4b1e62d25fb96830a62">yyjson_mut_obj_add</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *obj, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *key,<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *val);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Adds a key-value pair to the object.</span></div>
<div class="line"><span class="comment">// The key must be a string value.</span></div>
<div class="line"><span class="comment">// This function may remove all key-value pairs for the given key before add.</span></div>
<div class="line"><span class="comment">// Note that this function takes a linear search time.</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#acbfde7c1173b4258f83029c6dacf47c3">yyjson_mut_obj_put</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *obj, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *key, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *val);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Removes key-value pair from the object with a given key.</span></div>
<div class="line"><span class="comment">// Note that this function takes a linear search time.</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a660d533ce8b661e85c5b14e4e99e5085">yyjson_mut_obj_remove</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *obj, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *key);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Removes all key-value pairs in this object.</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#aee5bc7d2ad2169a04f54e63139eddb86">yyjson_mut_obj_clear</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *obj);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Convenience API:</span></div>
<div class="line"><span class="comment">// Adds a key-value pair at the end of the object. The key is not copied.</span></div>
<div class="line"><span class="comment">// Note that these functions allow duplicated key in one object.</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a6efc657d7f9aefdcba51e753fcea02c1">yyjson_mut_obj_add_null</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *obj, <span class="keyword">const</span> <span class="keywordtype">char</span> *key);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a80380f14a448ea046eb718e068c2df6b">yyjson_mut_obj_add_true</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *obj, <span class="keyword">const</span> <span class="keywordtype">char</span> *key);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a52c88fea8622d7bf4e81ecea93dc5df6">yyjson_mut_obj_add_false</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *obj, <span class="keyword">const</span> <span class="keywordtype">char</span> *key);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#abe2f1b0c0b8cb9ceab3cdc35d4574c86">yyjson_mut_obj_add_bool</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *obj, <span class="keyword">const</span> <span class="keywordtype">char</span> *key, <span class="keywordtype">bool</span> val);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a5f48e712fe4988f779a35309779dd765">yyjson_mut_obj_add_uint</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *obj, <span class="keyword">const</span> <span class="keywordtype">char</span> *key, uint64_t val);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a4070a94fca9592eefa2798dd45237d85">yyjson_mut_obj_add_sint</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *obj, <span class="keyword">const</span> <span class="keywordtype">char</span> *key, int64_t val);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a56726ff7e284700736e26e56afa6cf7b">yyjson_mut_obj_add_int</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *obj, <span class="keyword">const</span> <span class="keywordtype">char</span> *key, int64_t val);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#aead391adc0e8fba55c0b230ac4d36612">yyjson_mut_obj_add_float</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *obj, <span class="keyword">const</span> <span class="keywordtype">char</span> *key, <span class="keywordtype">float</span> val);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a29d6ef8f7bf8135d9b7d93cb4c7d2c0c">yyjson_mut_obj_add_double</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *obj, <span class="keyword">const</span> <span class="keywordtype">char</span> *key, <span class="keywordtype">double</span> val);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#aa4b243e9de837405d83bcc3251156cea">yyjson_mut_obj_add_real</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *obj, <span class="keyword">const</span> <span class="keywordtype">char</span> *key, <span class="keywordtype">double</span> val);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a996f8aa51f4c1475448974cf98f28df3">yyjson_mut_obj_add_str</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *obj, <span class="keyword">const</span> <span class="keywordtype">char</span> *key, <span class="keyword">const</span> <span class="keywordtype">char</span> *val);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a4530f9fc02f8604cef3de273feb4ab6a">yyjson_mut_obj_add_strn</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *obj, <span class="keyword">const</span> <span class="keywordtype">char</span> *key, <span class="keyword">const</span> <span class="keywordtype">char</span> *val, <span class="keywordtype">size_t</span> len);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#abeeca08e3b6994dddd55951a83cd648f">yyjson_mut_obj_add_strcpy</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *obj, <span class="keyword">const</span> <span class="keywordtype">char</span> *key, <span class="keyword">const</span> <span class="keywordtype">char</span> *val);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a1d544048860a8c53510d560b4d60411a">yyjson_mut_obj_add_strncpy</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *obj, <span class="keyword">const</span> <span class="keywordtype">char</span> *key, <span class="keyword">const</span> <span class="keywordtype">char</span> *val, <span class="keywordtype">size_t</span> len);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a1d27c9ad366209b83f236d74ec7e1991">yyjson_mut_obj_add_arr</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *obj, <span class="keyword">const</span> <span class="keywordtype">char</span> *_key);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a7241260b7fefbbdfdf7566d207b486c5">yyjson_mut_obj_add_obj</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *obj, <span class="keyword">const</span> <span class="keywordtype">char</span> *_key);</div>
<div class="line">                              </div>
<div class="line"><span class="comment">// Convenience API:</span></div>
<div class="line"><span class="comment">// Removes all key-value pairs for the given key.</span></div>
<div class="line"><span class="comment">// Note that this function takes a linear search time.</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a630b55e2937f7ffe8c0dcef20497ce93">yyjson_mut_obj_remove_str</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *obj, <span class="keyword">const</span> <span class="keywordtype">char</span> *key);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#ae6dfd237f7997125e606d678b3b59b5c">yyjson_mut_obj_remove_strn</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *obj, <span class="keyword">const</span> <span class="keywordtype">char</span> *key, <span class="keywordtype">size_t</span> len);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Convenience API:</span></div>
<div class="line"><span class="comment">// Replaces all matching keys with the new key.</span></div>
<div class="line"><span class="comment">// Returns true if at least one key was renamed.</span></div>
<div class="line"><span class="comment">// This function takes a linear search time.</span></div>
<div class="line"><a class="code hl_define" href="yyjson_8h.html#a682886dc8be2307076b125b496b15570">yyjson_api_inline</a> <span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#aea65c64007cfa236faa17e1ac87c4e5e">yyjson_mut_obj_rename_key</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *obj, <span class="keyword">const</span> <span class="keywordtype">char</span> *key, <span class="keyword">const</span> <span class="keywordtype">char</span> *new_key);</div>
<div class="line"><a class="code hl_define" href="yyjson_8h.html#a682886dc8be2307076b125b496b15570">yyjson_api_inline</a> <span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a335b9fdffa2885eb5eddd1ee2b43016b">yyjson_mut_obj_rename_keyn</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *obj, <span class="keyword">const</span> <span class="keywordtype">char</span> *key, <span class="keywordtype">size_t</span> len, <span class="keyword">const</span> <span class="keywordtype">char</span> *new_key, <span class="keywordtype">size_t</span> new_len);</div>
<div class="ttc" id="ayyjson_8h_html_a1d27c9ad366209b83f236d74ec7e1991"><div class="ttname"><a href="yyjson_8h.html#a1d27c9ad366209b83f236d74ec7e1991">yyjson_mut_obj_add_arr</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_add_arr(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key)</div><div class="ttdef"><b>Definition</b> yyjson.h:7281</div></div>
<div class="ttc" id="ayyjson_8h_html_a1d544048860a8c53510d560b4d60411a"><div class="ttname"><a href="yyjson_8h.html#a1d544048860a8c53510d560b4d60411a">yyjson_mut_obj_add_strncpy</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_obj_add_strncpy(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, const char *val, size_t len)</div><div class="ttdef"><b>Definition</b> yyjson.h:7268</div></div>
<div class="ttc" id="ayyjson_8h_html_a29d6ef8f7bf8135d9b7d93cb4c7d2c0c"><div class="ttname"><a href="yyjson_8h.html#a29d6ef8f7bf8135d9b7d93cb4c7d2c0c">yyjson_mut_obj_add_double</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_obj_add_double(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, double val)</div><div class="ttdef"><b>Definition</b> yyjson.h:7215</div></div>
<div class="ttc" id="ayyjson_8h_html_a335b9fdffa2885eb5eddd1ee2b43016b"><div class="ttname"><a href="yyjson_8h.html#a335b9fdffa2885eb5eddd1ee2b43016b">yyjson_mut_obj_rename_keyn</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_obj_rename_keyn(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, size_t len, const char *new_key, size_t new_len)</div><div class="ttdef"><b>Definition</b> yyjson.h:7339</div></div>
<div class="ttc" id="ayyjson_8h_html_a4070a94fca9592eefa2798dd45237d85"><div class="ttname"><a href="yyjson_8h.html#a4070a94fca9592eefa2798dd45237d85">yyjson_mut_obj_add_sint</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_obj_add_sint(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, int64_t val)</div><div class="ttdef"><b>Definition</b> yyjson.h:7194</div></div>
<div class="ttc" id="ayyjson_8h_html_a4530f9fc02f8604cef3de273feb4ab6a"><div class="ttname"><a href="yyjson_8h.html#a4530f9fc02f8604cef3de273feb4ab6a">yyjson_mut_obj_add_strn</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_obj_add_strn(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, const char *val, size_t len)</div><div class="ttdef"><b>Definition</b> yyjson.h:7243</div></div>
<div class="ttc" id="ayyjson_8h_html_a52c88fea8622d7bf4e81ecea93dc5df6"><div class="ttname"><a href="yyjson_8h.html#a52c88fea8622d7bf4e81ecea93dc5df6">yyjson_mut_obj_add_false</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_obj_add_false(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key)</div><div class="ttdef"><b>Definition</b> yyjson.h:7174</div></div>
<div class="ttc" id="ayyjson_8h_html_a56726ff7e284700736e26e56afa6cf7b"><div class="ttname"><a href="yyjson_8h.html#a56726ff7e284700736e26e56afa6cf7b">yyjson_mut_obj_add_int</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_obj_add_int(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, int64_t val)</div><div class="ttdef"><b>Definition</b> yyjson.h:7201</div></div>
<div class="ttc" id="ayyjson_8h_html_a5f48e712fe4988f779a35309779dd765"><div class="ttname"><a href="yyjson_8h.html#a5f48e712fe4988f779a35309779dd765">yyjson_mut_obj_add_uint</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_obj_add_uint(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, uint64_t val)</div><div class="ttdef"><b>Definition</b> yyjson.h:7187</div></div>
<div class="ttc" id="ayyjson_8h_html_a630b55e2937f7ffe8c0dcef20497ce93"><div class="ttname"><a href="yyjson_8h.html#a630b55e2937f7ffe8c0dcef20497ce93">yyjson_mut_obj_remove_str</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_remove_str(yyjson_mut_val *obj, const char *key)</div><div class="ttdef"><b>Definition</b> yyjson.h:7307</div></div>
<div class="ttc" id="ayyjson_8h_html_a660d533ce8b661e85c5b14e4e99e5085"><div class="ttname"><a href="yyjson_8h.html#a660d533ce8b661e85c5b14e4e99e5085">yyjson_mut_obj_remove</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_remove(yyjson_mut_val *obj, yyjson_mut_val *key)</div><div class="ttdef"><b>Definition</b> yyjson.h:7083</div></div>
<div class="ttc" id="ayyjson_8h_html_a682886dc8be2307076b125b496b15570"><div class="ttname"><a href="yyjson_8h.html#a682886dc8be2307076b125b496b15570">yyjson_api_inline</a></div><div class="ttdeci">#define yyjson_api_inline</div><div class="ttdef"><b>Definition</b> yyjson.h:340</div></div>
<div class="ttc" id="ayyjson_8h_html_a6efc657d7f9aefdcba51e753fcea02c1"><div class="ttname"><a href="yyjson_8h.html#a6efc657d7f9aefdcba51e753fcea02c1">yyjson_mut_obj_add_null</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_obj_add_null(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key)</div><div class="ttdef"><b>Definition</b> yyjson.h:7162</div></div>
<div class="ttc" id="ayyjson_8h_html_a7241260b7fefbbdfdf7566d207b486c5"><div class="ttname"><a href="yyjson_8h.html#a7241260b7fefbbdfdf7566d207b486c5">yyjson_mut_obj_add_obj</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_add_obj(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key)</div><div class="ttdef"><b>Definition</b> yyjson.h:7289</div></div>
<div class="ttc" id="ayyjson_8h_html_a80380f14a448ea046eb718e068c2df6b"><div class="ttname"><a href="yyjson_8h.html#a80380f14a448ea046eb718e068c2df6b">yyjson_mut_obj_add_true</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_obj_add_true(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key)</div><div class="ttdef"><b>Definition</b> yyjson.h:7168</div></div>
<div class="ttc" id="ayyjson_8h_html_a996f8aa51f4c1475448974cf98f28df3"><div class="ttname"><a href="yyjson_8h.html#a996f8aa51f4c1475448974cf98f28df3">yyjson_mut_obj_add_str</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_obj_add_str(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, const char *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:7229</div></div>
<div class="ttc" id="ayyjson_8h_html_aa4b243e9de837405d83bcc3251156cea"><div class="ttname"><a href="yyjson_8h.html#aa4b243e9de837405d83bcc3251156cea">yyjson_mut_obj_add_real</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_obj_add_real(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, double val)</div><div class="ttdef"><b>Definition</b> yyjson.h:7222</div></div>
<div class="ttc" id="ayyjson_8h_html_abe2f1b0c0b8cb9ceab3cdc35d4574c86"><div class="ttname"><a href="yyjson_8h.html#abe2f1b0c0b8cb9ceab3cdc35d4574c86">yyjson_mut_obj_add_bool</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_obj_add_bool(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, bool val)</div><div class="ttdef"><b>Definition</b> yyjson.h:7180</div></div>
<div class="ttc" id="ayyjson_8h_html_abeeca08e3b6994dddd55951a83cd648f"><div class="ttname"><a href="yyjson_8h.html#abeeca08e3b6994dddd55951a83cd648f">yyjson_mut_obj_add_strcpy</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_obj_add_strcpy(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, const char *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:7255</div></div>
<div class="ttc" id="ayyjson_8h_html_acbfde7c1173b4258f83029c6dacf47c3"><div class="ttname"><a href="yyjson_8h.html#acbfde7c1173b4258f83029c6dacf47c3">yyjson_mut_obj_put</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_obj_put(yyjson_mut_val *obj, yyjson_mut_val *key, yyjson_mut_val *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:7035</div></div>
<div class="ttc" id="ayyjson_8h_html_ae6dfd237f7997125e606d678b3b59b5c"><div class="ttname"><a href="yyjson_8h.html#ae6dfd237f7997125e606d678b3b59b5c">yyjson_mut_obj_remove_strn</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_remove_strn(yyjson_mut_val *obj, const char *key, size_t len)</div><div class="ttdef"><b>Definition</b> yyjson.h:7312</div></div>
<div class="ttc" id="ayyjson_8h_html_aea65c64007cfa236faa17e1ac87c4e5e"><div class="ttname"><a href="yyjson_8h.html#aea65c64007cfa236faa17e1ac87c4e5e">yyjson_mut_obj_rename_key</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_obj_rename_key(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, const char *new_key)</div><div class="ttdef"><b>Definition</b> yyjson.h:7330</div></div>
<div class="ttc" id="ayyjson_8h_html_aead391adc0e8fba55c0b230ac4d36612"><div class="ttname"><a href="yyjson_8h.html#aead391adc0e8fba55c0b230ac4d36612">yyjson_mut_obj_add_float</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_obj_add_float(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, float val)</div><div class="ttdef"><b>Definition</b> yyjson.h:7208</div></div>
<div class="ttc" id="ayyjson_8h_html_aee5bc7d2ad2169a04f54e63139eddb86"><div class="ttname"><a href="yyjson_8h.html#aee5bc7d2ad2169a04f54e63139eddb86">yyjson_mut_obj_clear</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_obj_clear(yyjson_mut_val *obj)</div><div class="ttdef"><b>Definition</b> yyjson.h:7109</div></div>
</div><!-- fragment --><hr  />
 <h1><a class="anchor" id="json-pointer-and-patch"></a>
JSON Pointer and Patch</h1>
<h2><a class="anchor" id="json-pointer"></a>
JSON Pointer</h2>
<p>The library supports querying JSON values using <code>JSON Pointer</code> (<a href="https://tools.ietf.org/html/rfc6901">RFC 6901</a>).</p>
<div class="fragment"><div class="line"><span class="comment">// `JSON pointer` is a null-terminated string.</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *<a class="code hl_function" href="yyjson_8h.html#a897cf07015f4f79fb4ebb0b3f58ac292">yyjson_ptr_get</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val, <span class="keyword">const</span> <span class="keywordtype">char</span> *ptr);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *<a class="code hl_function" href="yyjson_8h.html#a9a9b30d275e211df9b84b91f4b95907a">yyjson_doc_ptr_get</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *doc, <span class="keyword">const</span> <span class="keywordtype">char</span> *ptr);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a8add57045c09758844b9433dbe3d4451">yyjson_mut_ptr_get</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *val, <span class="keyword">const</span> <span class="keywordtype">char</span> *ptr);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a5ad2700fe7073292adb71d508a049604">yyjson_mut_doc_ptr_get</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keyword">const</span> <span class="keywordtype">char</span> *ptr);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// `JSON pointer` with string length, allow NUL (Unicode U+0000) characters inside.</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *<a class="code hl_function" href="yyjson_8h.html#aa3612af25f159df0c0587ddf8c7c58db">yyjson_ptr_getn</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val, <span class="keyword">const</span> <span class="keywordtype">char</span> *ptr, <span class="keywordtype">size_t</span> len);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *<a class="code hl_function" href="yyjson_8h.html#a5b12a7b59d79123f9de71510efa2df3d">yyjson_doc_ptr_getn</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *doc, <span class="keyword">const</span> <span class="keywordtype">char</span> *ptr, <span class="keywordtype">size_t</span> len);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a7d72991b7e14b54845b639ef37c1c54c">yyjson_mut_ptr_getn</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *val, <span class="keyword">const</span> <span class="keywordtype">char</span> *ptr, <span class="keywordtype">size_t</span> len);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a085db50b4cf005e489b7401281ea8636">yyjson_mut_doc_ptr_getn</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keyword">const</span> <span class="keywordtype">char</span> *ptr, <span class="keywordtype">size_t</span> len);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// `JSON pointer` with string length, context and error information.</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *<a class="code hl_function" href="yyjson_8h.html#a4b69d3a0061294fecd4a94927ad10e96">yyjson_ptr_getx</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val, <span class="keyword">const</span> <span class="keywordtype">char</span> *ptr, <span class="keywordtype">size_t</span> len, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__ptr__err">yyjson_ptr_err</a> *err);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *<a class="code hl_function" href="yyjson_8h.html#a53930a7b337295aefe993760fcc05645">yyjson_doc_ptr_getx</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *doc, <span class="keyword">const</span> <span class="keywordtype">char</span> *ptr, <span class="keywordtype">size_t</span> len, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__ptr__err">yyjson_ptr_err</a> *err);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#abb1b3f84ca4f32c72dad8eea83f3d116">yyjson_mut_ptr_getx</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *val, <span class="keyword">const</span> <span class="keywordtype">char</span> *ptr, <span class="keywordtype">size_t</span> len, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__ptr__ctx">yyjson_ptr_ctx</a> *ctx, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__ptr__err">yyjson_ptr_err</a> *err);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a6031b6b35b06127f3fa2278be67c29ea">yyjson_mut_doc_ptr_getx</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keyword">const</span> <span class="keywordtype">char</span> *ptr, <span class="keywordtype">size_t</span> len, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__ptr__ctx">yyjson_ptr_ctx</a> *ctx, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__ptr__err">yyjson_ptr_err</a> *err);</div>
<div class="ttc" id="ayyjson_8h_html_a085db50b4cf005e489b7401281ea8636"><div class="ttname"><a href="yyjson_8h.html#a085db50b4cf005e489b7401281ea8636">yyjson_mut_doc_ptr_getn</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_doc_ptr_getn(yyjson_mut_doc *doc, const char *ptr, size_t len)</div><div class="ttdef"><b>Definition</b> yyjson.h:7479</div></div>
<div class="ttc" id="ayyjson_8h_html_a4b69d3a0061294fecd4a94927ad10e96"><div class="ttname"><a href="yyjson_8h.html#a4b69d3a0061294fecd4a94927ad10e96">yyjson_ptr_getx</a></div><div class="ttdeci">yyjson_api_inline yyjson_val * yyjson_ptr_getx(yyjson_val *val, const char *ptr, size_t len, yyjson_ptr_err *err)</div><div class="ttdef"><b>Definition</b> yyjson.h:7455</div></div>
<div class="ttc" id="ayyjson_8h_html_a53930a7b337295aefe993760fcc05645"><div class="ttname"><a href="yyjson_8h.html#a53930a7b337295aefe993760fcc05645">yyjson_doc_ptr_getx</a></div><div class="ttdeci">yyjson_api_inline yyjson_val * yyjson_doc_ptr_getx(yyjson_doc *doc, const char *ptr, size_t len, yyjson_ptr_err *err)</div><div class="ttdef"><b>Definition</b> yyjson.h:7422</div></div>
<div class="ttc" id="ayyjson_8h_html_a5ad2700fe7073292adb71d508a049604"><div class="ttname"><a href="yyjson_8h.html#a5ad2700fe7073292adb71d508a049604">yyjson_mut_doc_ptr_get</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_doc_ptr_get(yyjson_mut_doc *doc, const char *ptr)</div><div class="ttdef"><b>Definition</b> yyjson.h:7473</div></div>
<div class="ttc" id="ayyjson_8h_html_a5b12a7b59d79123f9de71510efa2df3d"><div class="ttname"><a href="yyjson_8h.html#a5b12a7b59d79123f9de71510efa2df3d">yyjson_doc_ptr_getn</a></div><div class="ttdeci">yyjson_api_inline yyjson_val * yyjson_doc_ptr_getn(yyjson_doc *doc, const char *ptr, size_t len)</div><div class="ttdef"><b>Definition</b> yyjson.h:7417</div></div>
<div class="ttc" id="ayyjson_8h_html_a6031b6b35b06127f3fa2278be67c29ea"><div class="ttname"><a href="yyjson_8h.html#a6031b6b35b06127f3fa2278be67c29ea">yyjson_mut_doc_ptr_getx</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_doc_ptr_getx(yyjson_mut_doc *doc, const char *ptr, size_t len, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err)</div><div class="ttdef"><b>Definition</b> yyjson.h:7485</div></div>
<div class="ttc" id="ayyjson_8h_html_a7d72991b7e14b54845b639ef37c1c54c"><div class="ttname"><a href="yyjson_8h.html#a7d72991b7e14b54845b639ef37c1c54c">yyjson_mut_ptr_getn</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_ptr_getn(yyjson_mut_val *val, const char *ptr, size_t len)</div><div class="ttdef"><b>Definition</b> yyjson.h:7517</div></div>
<div class="ttc" id="ayyjson_8h_html_a897cf07015f4f79fb4ebb0b3f58ac292"><div class="ttname"><a href="yyjson_8h.html#a897cf07015f4f79fb4ebb0b3f58ac292">yyjson_ptr_get</a></div><div class="ttdeci">yyjson_api_inline yyjson_val * yyjson_ptr_get(yyjson_val *val, const char *ptr)</div><div class="ttdef"><b>Definition</b> yyjson.h:7444</div></div>
<div class="ttc" id="ayyjson_8h_html_a8add57045c09758844b9433dbe3d4451"><div class="ttname"><a href="yyjson_8h.html#a8add57045c09758844b9433dbe3d4451">yyjson_mut_ptr_get</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_ptr_get(yyjson_mut_val *val, const char *ptr)</div><div class="ttdef"><b>Definition</b> yyjson.h:7511</div></div>
<div class="ttc" id="ayyjson_8h_html_a9a9b30d275e211df9b84b91f4b95907a"><div class="ttname"><a href="yyjson_8h.html#a9a9b30d275e211df9b84b91f4b95907a">yyjson_doc_ptr_get</a></div><div class="ttdeci">yyjson_api_inline yyjson_val * yyjson_doc_ptr_get(yyjson_doc *doc, const char *ptr)</div><div class="ttdef"><b>Definition</b> yyjson.h:7411</div></div>
<div class="ttc" id="ayyjson_8h_html_aa3612af25f159df0c0587ddf8c7c58db"><div class="ttname"><a href="yyjson_8h.html#aa3612af25f159df0c0587ddf8c7c58db">yyjson_ptr_getn</a></div><div class="ttdeci">yyjson_api_inline yyjson_val * yyjson_ptr_getn(yyjson_val *val, const char *ptr, size_t len)</div><div class="ttdef"><b>Definition</b> yyjson.h:7450</div></div>
<div class="ttc" id="ayyjson_8h_html_abb1b3f84ca4f32c72dad8eea83f3d116"><div class="ttname"><a href="yyjson_8h.html#abb1b3f84ca4f32c72dad8eea83f3d116">yyjson_mut_ptr_getx</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_ptr_getx(yyjson_mut_val *val, const char *ptr, size_t len, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err)</div><div class="ttdef"><b>Definition</b> yyjson.h:7523</div></div>
<div class="ttc" id="ayyjson_8h_html_structyyjson__ptr__ctx"><div class="ttname"><a href="yyjson_8h.html#structyyjson__ptr__ctx">yyjson_ptr_ctx</a></div><div class="ttdef"><b>Definition</b> yyjson.h:4120</div></div>
<div class="ttc" id="ayyjson_8h_html_structyyjson__ptr__err"><div class="ttname"><a href="yyjson_8h.html#structyyjson__ptr__err">yyjson_ptr_err</a></div><div class="ttdef"><b>Definition</b> yyjson.h:4092</div></div>
</div><!-- fragment --><p>For example, given the JSON document: </p><div class="fragment"><div class="line">{</div>
<div class="line">    &quot;size&quot; : 3,</div>
<div class="line">    &quot;users&quot; : [</div>
<div class="line">        {&quot;id&quot;: 1, &quot;name&quot;: &quot;Harry&quot;},</div>
<div class="line">        {&quot;id&quot;: 2, &quot;name&quot;: &quot;Ron&quot;},</div>
<div class="line">        {&quot;id&quot;: 3, &quot;name&quot;: &quot;Hermione&quot;}</div>
<div class="line">    ]</div>
<div class="line">}</div>
</div><!-- fragment --><p> The following JSON strings evaluate to the accompanying values:</p>
<table class="markdownTable">
<tr class="markdownTableHead">
<th class="markdownTableHeadLeft">Pointer   </th><th class="markdownTableHeadLeft">Matched Value    </th></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyLeft"><code>""</code>   </td><td class="markdownTableBodyLeft"><code>the whole document</code>    </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyLeft"><code>"/size"</code>   </td><td class="markdownTableBodyLeft"><code>3</code>    </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyLeft"><code>"/users/0"</code>   </td><td class="markdownTableBodyLeft"><code>{"id": 1, "name": "Harry"}</code>    </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyLeft"><code>"/users/1/name"</code>   </td><td class="markdownTableBodyLeft"><code>"Ron"</code>    </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyLeft"><code>"/no_match"</code>   </td><td class="markdownTableBodyLeft">NULL    </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyLeft"><code>"no_slash"</code>   </td><td class="markdownTableBodyLeft">NULL    </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyLeft"><code>"/"</code>   </td><td class="markdownTableBodyLeft">NULL (match to empty key: root[""])   </td></tr>
</table>
<div class="fragment"><div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *doc = ...;</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val = <a class="code hl_function" href="yyjson_8h.html#a9a9b30d275e211df9b84b91f4b95907a">yyjson_doc_ptr_get</a>(doc, <span class="stringliteral">&quot;/users/1/name&quot;</span>);</div>
<div class="line">printf(<span class="stringliteral">&quot;%s\n&quot;</span>, <a class="code hl_function" href="yyjson_8h.html#a986e994db00b2749e000af0a4331454c">yyjson_get_str</a>(val)); <span class="comment">// Ron</span></div>
<div class="line"> </div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__ptr__err">yyjson_ptr_err</a> err;</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val2 = <a class="code hl_function" href="yyjson_8h.html#a53930a7b337295aefe993760fcc05645">yyjson_doc_ptr_getx</a>(doc, <span class="stringliteral">&quot;/&quot;</span>, 1, &amp;err);</div>
<div class="line"><span class="keywordflow">if</span> (!val2) printf(<span class="stringliteral">&quot;err %d: %s\n&quot;</span>, err.<a class="code hl_variable" href="yyjson_8h.html#ac82ebe0c715ad673a943e784f325b538">code</a>, err.<a class="code hl_variable" href="yyjson_8h.html#a4d811ed5e9271667460dc1dc491d3295">msg</a>); <span class="comment">// err 3: cannot be resolved</span></div>
<div class="ttc" id="ayyjson_8h_html_a4d811ed5e9271667460dc1dc491d3295"><div class="ttname"><a href="yyjson_8h.html#a4d811ed5e9271667460dc1dc491d3295">yyjson_ptr_err::msg</a></div><div class="ttdeci">const char * msg</div><div class="ttdef"><b>Definition</b> yyjson.h:4096</div></div>
<div class="ttc" id="ayyjson_8h_html_ac82ebe0c715ad673a943e784f325b538"><div class="ttname"><a href="yyjson_8h.html#ac82ebe0c715ad673a943e784f325b538">yyjson_ptr_err::code</a></div><div class="ttdeci">yyjson_ptr_code code</div><div class="ttdef"><b>Definition</b> yyjson.h:4094</div></div>
</div><!-- fragment --><p>The library also supports modifying JSON values using <code>JSON Pointer</code>. </p><div class="fragment"><div class="line"><span class="comment">// Add or insert a new value.</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#ab49d3e532c97846b198b360602a9b5ca">yyjson_mut_ptr_add</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *val, <span class="keyword">const</span> <span class="keywordtype">char</span> *ptr, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *new_val, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#aa65216783e9cd2ff949092399a2608d8">yyjson_mut_ptr_addn</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *val, <span class="keyword">const</span> <span class="keywordtype">char</span> *ptr, <span class="keywordtype">size_t</span> len, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *new_val, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a256b4f50ed8e6830d57fbf7df7053141">yyjson_mut_ptr_addx</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *val, <span class="keyword">const</span> <span class="keywordtype">char</span> *ptr, <span class="keywordtype">size_t</span> len, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *new_val, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keywordtype">bool</span> create_parent, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__ptr__ctx">yyjson_ptr_ctx</a> *ctx, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__ptr__err">yyjson_ptr_err</a> *err);</div>
<div class="line">                                           </div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#ae1a372cfbbc8a536decaf1db5223804d">yyjson_mut_doc_ptr_add</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keyword">const</span> <span class="keywordtype">char</span> *ptr, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *new_val);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a5ee67bcb7012b25bd3bd7f88e5bb1699">yyjson_mut_doc_ptr_addn</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keyword">const</span> <span class="keywordtype">char</span> *ptr, <span class="keywordtype">size_t</span> len, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *new_val);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#ad284e6ee4236ffa0be5d45625d57cac4">yyjson_mut_doc_ptr_addx</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keyword">const</span> <span class="keywordtype">char</span> *ptr, <span class="keywordtype">size_t</span> len, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *new_val, <span class="keywordtype">bool</span> create_parent, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__ptr__ctx">yyjson_ptr_ctx</a> *ctx, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__ptr__err">yyjson_ptr_err</a> *err);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Set a new value (add if it doesn&#39;t exist, replace if it does).</span></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a4de077663ebedc11a24ddbde66a72945">yyjson_mut_ptr_set</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *val, <span class="keyword">const</span> <span class="keywordtype">char</span> *ptr, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *new_val, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#ac8ba98e62d5d4c5ab9ddd44173164756">yyjson_mut_ptr_setn</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *val, <span class="keyword">const</span> <span class="keywordtype">char</span> *ptr, <span class="keywordtype">size_t</span> len, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *new_val, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a181de44520dcd7eb3211c617d10f4525">yyjson_mut_ptr_setx</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *val, <span class="keyword">const</span> <span class="keywordtype">char</span> *ptr, <span class="keywordtype">size_t</span> len, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *new_val, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keywordtype">bool</span> create_parent, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__ptr__ctx">yyjson_ptr_ctx</a> *ctx, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__ptr__err">yyjson_ptr_err</a> *err);</div>
<div class="line">                                             </div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a6c844108b8cdd6583802570b1500630c">yyjson_mut_doc_ptr_set</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keyword">const</span> <span class="keywordtype">char</span> *ptr, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *new_val);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a222fa618ed3b7f6cbd355bb04708498f">yyjson_mut_doc_ptr_setn</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keyword">const</span> <span class="keywordtype">char</span> *ptr, <span class="keywordtype">size_t</span> len, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *new_val);</div>
<div class="line"><span class="keywordtype">bool</span> <a class="code hl_function" href="yyjson_8h.html#a48213b9742ba7fe6fb54b79be2da1f97">yyjson_mut_doc_ptr_setx</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keyword">const</span> <span class="keywordtype">char</span> *ptr, <span class="keywordtype">size_t</span> len, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *new_val, <span class="keywordtype">bool</span> create_parent, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__ptr__ctx">yyjson_ptr_ctx</a> *ctx, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__ptr__err">yyjson_ptr_err</a> *err);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Replace an existing value.</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#ad617af11eb6bf81926531878f0117bba">yyjson_mut_ptr_replace</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *val, <span class="keyword">const</span> <span class="keywordtype">char</span> *ptr, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *new_val);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#af324a76bd5e45899cccba7850d9ce43a">yyjson_mut_ptr_replacen</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *val, <span class="keyword">const</span> <span class="keywordtype">char</span> *ptr, <span class="keywordtype">size_t</span> len, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *new_val);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a41f9c6e4641f813a7a94f12ea79b34ce">yyjson_mut_ptr_replacex</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *val, <span class="keyword">const</span> <span class="keywordtype">char</span> *ptr, <span class="keywordtype">size_t</span> len, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *new_val, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__ptr__ctx">yyjson_ptr_ctx</a> *ctx, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__ptr__err">yyjson_ptr_err</a> *err);</div>
<div class="line">    </div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a1a52947332757bebf28985bad6fb3d5d">yyjson_mut_doc_ptr_replace</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keyword">const</span> <span class="keywordtype">char</span> *ptr, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *new_val);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a71d44a9f504b50eab96e59d348b2553f">yyjson_mut_doc_ptr_replacen</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keyword">const</span> <span class="keywordtype">char</span> *ptr, <span class="keywordtype">size_t</span> len, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *new_val);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#aed5fc7ff1c73fd7a1829e863ce92ad65">yyjson_mut_doc_ptr_replacex</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keyword">const</span> <span class="keywordtype">char</span> *ptr, <span class="keywordtype">size_t</span> len, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *new_val, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__ptr__ctx">yyjson_ptr_ctx</a> *ctx, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__ptr__err">yyjson_ptr_err</a> *err);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Remove an existing value.</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a853738b59790700627f7212b6e00922d">yyjson_mut_ptr_remove</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *val, <span class="keyword">const</span> <span class="keywordtype">char</span> *ptr);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a3447370d5ab7657cd98c54ef17fb047b">yyjson_mut_ptr_removen</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *val, <span class="keyword">const</span> <span class="keywordtype">char</span> *ptr, <span class="keywordtype">size_t</span> len);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a68a954cfda2a17cc612bb31460b902e1">yyjson_mut_ptr_removex</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *val, <span class="keyword">const</span> <span class="keywordtype">char</span> *ptr, <span class="keywordtype">size_t</span> len, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__ptr__ctx">yyjson_ptr_ctx</a> *ctx, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__ptr__err">yyjson_ptr_err</a> *err);</div>
<div class="line"> </div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a0358ed2cf421e64f5052068f41ca8f26">yyjson_mut_doc_ptr_remove</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keyword">const</span> <span class="keywordtype">char</span> *ptr);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a4ede66b0b130faa9af1c47878cf52be2">yyjson_mut_doc_ptr_removen</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keyword">const</span> <span class="keywordtype">char</span> *ptr, <span class="keywordtype">size_t</span> len);</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a286f0920116870a3d27b466c515234a3">yyjson_mut_doc_ptr_removex</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc, <span class="keyword">const</span> <span class="keywordtype">char</span> *ptr, <span class="keywordtype">size_t</span> len, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__ptr__ctx">yyjson_ptr_ctx</a> *ctx, <a class="code hl_struct" href="yyjson_8h.html#structyyjson__ptr__err">yyjson_ptr_err</a> *err);</div>
<div class="ttc" id="ayyjson_8h_html_a0358ed2cf421e64f5052068f41ca8f26"><div class="ttname"><a href="yyjson_8h.html#a0358ed2cf421e64f5052068f41ca8f26">yyjson_mut_doc_ptr_remove</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_doc_ptr_remove(yyjson_mut_doc *doc, const char *ptr)</div><div class="ttdef"><b>Definition</b> yyjson.h:7831</div></div>
<div class="ttc" id="ayyjson_8h_html_a181de44520dcd7eb3211c617d10f4525"><div class="ttname"><a href="yyjson_8h.html#a181de44520dcd7eb3211c617d10f4525">yyjson_mut_ptr_setx</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_ptr_setx(yyjson_mut_val *val, const char *ptr, size_t len, yyjson_mut_val *new_val, yyjson_mut_doc *doc, bool create_parent, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err)</div><div class="ttdef"><b>Definition</b> yyjson.h:7725</div></div>
<div class="ttc" id="ayyjson_8h_html_a1a52947332757bebf28985bad6fb3d5d"><div class="ttname"><a href="yyjson_8h.html#a1a52947332757bebf28985bad6fb3d5d">yyjson_mut_doc_ptr_replace</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_doc_ptr_replace(yyjson_mut_doc *doc, const char *ptr, yyjson_mut_val *new_val)</div><div class="ttdef"><b>Definition</b> yyjson.h:7754</div></div>
<div class="ttc" id="ayyjson_8h_html_a222fa618ed3b7f6cbd355bb04708498f"><div class="ttname"><a href="yyjson_8h.html#a222fa618ed3b7f6cbd355bb04708498f">yyjson_mut_doc_ptr_setn</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_doc_ptr_setn(yyjson_mut_doc *doc, const char *ptr, size_t len, yyjson_mut_val *new_val)</div><div class="ttdef"><b>Definition</b> yyjson.h:7654</div></div>
<div class="ttc" id="ayyjson_8h_html_a256b4f50ed8e6830d57fbf7df7053141"><div class="ttname"><a href="yyjson_8h.html#a256b4f50ed8e6830d57fbf7df7053141">yyjson_mut_ptr_addx</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_ptr_addx(yyjson_mut_val *val, const char *ptr, size_t len, yyjson_mut_val *new_val, yyjson_mut_doc *doc, bool create_parent, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err)</div><div class="ttdef"><b>Definition</b> yyjson.h:7621</div></div>
<div class="ttc" id="ayyjson_8h_html_a286f0920116870a3d27b466c515234a3"><div class="ttname"><a href="yyjson_8h.html#a286f0920116870a3d27b466c515234a3">yyjson_mut_doc_ptr_removex</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_doc_ptr_removex(yyjson_mut_doc *doc, const char *ptr, size_t len, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err)</div><div class="ttdef"><b>Definition</b> yyjson.h:7842</div></div>
<div class="ttc" id="ayyjson_8h_html_a3447370d5ab7657cd98c54ef17fb047b"><div class="ttname"><a href="yyjson_8h.html#a3447370d5ab7657cd98c54ef17fb047b">yyjson_mut_ptr_removen</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_ptr_removen(yyjson_mut_val *val, const char *ptr, size_t len)</div><div class="ttdef"><b>Definition</b> yyjson.h:7876</div></div>
<div class="ttc" id="ayyjson_8h_html_a41f9c6e4641f813a7a94f12ea79b34ce"><div class="ttname"><a href="yyjson_8h.html#a41f9c6e4641f813a7a94f12ea79b34ce">yyjson_mut_ptr_replacex</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_ptr_replacex(yyjson_mut_val *val, const char *ptr, size_t len, yyjson_mut_val *new_val, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err)</div><div class="ttdef"><b>Definition</b> yyjson.h:7809</div></div>
<div class="ttc" id="ayyjson_8h_html_a48213b9742ba7fe6fb54b79be2da1f97"><div class="ttname"><a href="yyjson_8h.html#a48213b9742ba7fe6fb54b79be2da1f97">yyjson_mut_doc_ptr_setx</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_doc_ptr_setx(yyjson_mut_doc *doc, const char *ptr, size_t len, yyjson_mut_val *new_val, bool create_parent, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err)</div><div class="ttdef"><b>Definition</b> yyjson.h:7660</div></div>
<div class="ttc" id="ayyjson_8h_html_a4de077663ebedc11a24ddbde66a72945"><div class="ttname"><a href="yyjson_8h.html#a4de077663ebedc11a24ddbde66a72945">yyjson_mut_ptr_set</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_ptr_set(yyjson_mut_val *val, const char *ptr, yyjson_mut_val *new_val, yyjson_mut_doc *doc)</div><div class="ttdef"><b>Definition</b> yyjson.h:7710</div></div>
<div class="ttc" id="ayyjson_8h_html_a4ede66b0b130faa9af1c47878cf52be2"><div class="ttname"><a href="yyjson_8h.html#a4ede66b0b130faa9af1c47878cf52be2">yyjson_mut_doc_ptr_removen</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_doc_ptr_removen(yyjson_mut_doc *doc, const char *ptr, size_t len)</div><div class="ttdef"><b>Definition</b> yyjson.h:7837</div></div>
<div class="ttc" id="ayyjson_8h_html_a5ee67bcb7012b25bd3bd7f88e5bb1699"><div class="ttname"><a href="yyjson_8h.html#a5ee67bcb7012b25bd3bd7f88e5bb1699">yyjson_mut_doc_ptr_addn</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_doc_ptr_addn(yyjson_mut_doc *doc, const char *ptr, size_t len, yyjson_mut_val *new_val)</div><div class="ttdef"><b>Definition</b> yyjson.h:7552</div></div>
<div class="ttc" id="ayyjson_8h_html_a68a954cfda2a17cc612bb31460b902e1"><div class="ttname"><a href="yyjson_8h.html#a68a954cfda2a17cc612bb31460b902e1">yyjson_mut_ptr_removex</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_ptr_removex(yyjson_mut_val *val, const char *ptr, size_t len, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err)</div><div class="ttdef"><b>Definition</b> yyjson.h:7882</div></div>
<div class="ttc" id="ayyjson_8h_html_a6c844108b8cdd6583802570b1500630c"><div class="ttname"><a href="yyjson_8h.html#a6c844108b8cdd6583802570b1500630c">yyjson_mut_doc_ptr_set</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_doc_ptr_set(yyjson_mut_doc *doc, const char *ptr, yyjson_mut_val *new_val)</div><div class="ttdef"><b>Definition</b> yyjson.h:7647</div></div>
<div class="ttc" id="ayyjson_8h_html_a71d44a9f504b50eab96e59d348b2553f"><div class="ttname"><a href="yyjson_8h.html#a71d44a9f504b50eab96e59d348b2553f">yyjson_mut_doc_ptr_replacen</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_doc_ptr_replacen(yyjson_mut_doc *doc, const char *ptr, size_t len, yyjson_mut_val *new_val)</div><div class="ttdef"><b>Definition</b> yyjson.h:7760</div></div>
<div class="ttc" id="ayyjson_8h_html_a853738b59790700627f7212b6e00922d"><div class="ttname"><a href="yyjson_8h.html#a853738b59790700627f7212b6e00922d">yyjson_mut_ptr_remove</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_ptr_remove(yyjson_mut_val *val, const char *ptr)</div><div class="ttdef"><b>Definition</b> yyjson.h:7870</div></div>
<div class="ttc" id="ayyjson_8h_html_aa65216783e9cd2ff949092399a2608d8"><div class="ttname"><a href="yyjson_8h.html#aa65216783e9cd2ff949092399a2608d8">yyjson_mut_ptr_addn</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_ptr_addn(yyjson_mut_val *val, const char *ptr, size_t len, yyjson_mut_val *new_val, yyjson_mut_doc *doc)</div><div class="ttdef"><b>Definition</b> yyjson.h:7614</div></div>
<div class="ttc" id="ayyjson_8h_html_ab49d3e532c97846b198b360602a9b5ca"><div class="ttname"><a href="yyjson_8h.html#ab49d3e532c97846b198b360602a9b5ca">yyjson_mut_ptr_add</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_ptr_add(yyjson_mut_val *val, const char *ptr, yyjson_mut_val *new_val, yyjson_mut_doc *doc)</div><div class="ttdef"><b>Definition</b> yyjson.h:7606</div></div>
<div class="ttc" id="ayyjson_8h_html_ac8ba98e62d5d4c5ab9ddd44173164756"><div class="ttname"><a href="yyjson_8h.html#ac8ba98e62d5d4c5ab9ddd44173164756">yyjson_mut_ptr_setn</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_ptr_setn(yyjson_mut_val *val, const char *ptr, size_t len, yyjson_mut_val *new_val, yyjson_mut_doc *doc)</div><div class="ttdef"><b>Definition</b> yyjson.h:7718</div></div>
<div class="ttc" id="ayyjson_8h_html_ad284e6ee4236ffa0be5d45625d57cac4"><div class="ttname"><a href="yyjson_8h.html#ad284e6ee4236ffa0be5d45625d57cac4">yyjson_mut_doc_ptr_addx</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_doc_ptr_addx(yyjson_mut_doc *doc, const char *ptr, size_t len, yyjson_mut_val *new_val, bool create_parent, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err)</div><div class="ttdef"><b>Definition</b> yyjson.h:7559</div></div>
<div class="ttc" id="ayyjson_8h_html_ad617af11eb6bf81926531878f0117bba"><div class="ttname"><a href="yyjson_8h.html#ad617af11eb6bf81926531878f0117bba">yyjson_mut_ptr_replace</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_ptr_replace(yyjson_mut_val *val, const char *ptr, yyjson_mut_val *new_val)</div><div class="ttdef"><b>Definition</b> yyjson.h:7798</div></div>
<div class="ttc" id="ayyjson_8h_html_ae1a372cfbbc8a536decaf1db5223804d"><div class="ttname"><a href="yyjson_8h.html#ae1a372cfbbc8a536decaf1db5223804d">yyjson_mut_doc_ptr_add</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_doc_ptr_add(yyjson_mut_doc *doc, const char *ptr, yyjson_mut_val *new_val)</div><div class="ttdef"><b>Definition</b> yyjson.h:7545</div></div>
<div class="ttc" id="ayyjson_8h_html_aed5fc7ff1c73fd7a1829e863ce92ad65"><div class="ttname"><a href="yyjson_8h.html#aed5fc7ff1c73fd7a1829e863ce92ad65">yyjson_mut_doc_ptr_replacex</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_doc_ptr_replacex(yyjson_mut_doc *doc, const char *ptr, size_t len, yyjson_mut_val *new_val, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err)</div><div class="ttdef"><b>Definition</b> yyjson.h:7765</div></div>
<div class="ttc" id="ayyjson_8h_html_af324a76bd5e45899cccba7850d9ce43a"><div class="ttname"><a href="yyjson_8h.html#af324a76bd5e45899cccba7850d9ce43a">yyjson_mut_ptr_replacen</a></div><div class="ttdeci">yyjson_api_inline yyjson_mut_val * yyjson_mut_ptr_replacen(yyjson_mut_val *val, const char *ptr, size_t len, yyjson_mut_val *new_val)</div><div class="ttdef"><b>Definition</b> yyjson.h:7804</div></div>
</div><!-- fragment --><p>For example: </p><div class="fragment"><div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc = ...;</div>
<div class="line"><span class="comment">// doc: {&quot;a&quot;:0,&quot;b&quot;:[1,2,3]}</span></div>
<div class="line"> </div>
<div class="line"><a class="code hl_function" href="yyjson_8h.html#a6c844108b8cdd6583802570b1500630c">yyjson_mut_doc_ptr_set</a>(doc, <span class="stringliteral">&quot;/a&quot;</span>, <a class="code hl_function" href="yyjson_8h.html#a92e202b3738250ffee612089bdec91eb">yyjson_mut_int</a>(doc, 9));</div>
<div class="line"><span class="comment">// now: {&quot;a&quot;:9,&quot;b&quot;:[1,2,3]}</span></div>
<div class="line"> </div>
<div class="line"><a class="code hl_function" href="yyjson_8h.html#ae1a372cfbbc8a536decaf1db5223804d">yyjson_mut_doc_ptr_add</a>(doc, <span class="stringliteral">&quot;/b/-&quot;</span>, <a class="code hl_function" href="yyjson_8h.html#a92e202b3738250ffee612089bdec91eb">yyjson_mut_int</a>(doc, 4));</div>
<div class="line"><span class="comment">// now: {&quot;a&quot;:9,&quot;b&quot;:[1,2,3,4]}</span></div>
<div class="line"> </div>
<div class="line"><a class="code hl_function" href="yyjson_8h.html#a0358ed2cf421e64f5052068f41ca8f26">yyjson_mut_doc_ptr_remove</a>(doc, <span class="stringliteral">&quot;/b&quot;</span>);</div>
<div class="line"><span class="comment">// now: {&quot;a&quot;:9}</span></div>
</div><!-- fragment --><p>All the above functions ending with <code>x</code> can be used to get the result context <code>ctx</code>, and the error message <code>err</code>. For example: </p><div class="fragment"><div class="line"><span class="comment">// doc: {&quot;a&quot;:0,&quot;b&quot;:[null,2,3]}</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc = ...;</div>
<div class="line"> </div>
<div class="line"><span class="comment">// get error code and message</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__ptr__err">yyjson_ptr_err</a> err;</div>
<div class="line"><a class="code hl_function" href="yyjson_8h.html#a48213b9742ba7fe6fb54b79be2da1f97">yyjson_mut_doc_ptr_setx</a>(doc, <span class="stringliteral">&quot;/b/99&quot;</span>, 4, <a class="code hl_function" href="yyjson_8h.html#a92e202b3738250ffee612089bdec91eb">yyjson_mut_int</a>(doc, 99), <span class="keyword">true</span>, NULL, &amp;err);</div>
<div class="line"><span class="keywordflow">if</span> (err.<a class="code hl_variable" href="yyjson_8h.html#ac82ebe0c715ad673a943e784f325b538">code</a>) printf(<span class="stringliteral">&quot;err: %s\n&quot;</span>, err.<a class="code hl_variable" href="yyjson_8h.html#a4d811ed5e9271667460dc1dc491d3295">msg</a>); <span class="comment">// err: cannot resolve</span></div>
<div class="line"> </div>
<div class="line"><span class="comment">// get target value&#39;s context</span></div>
<div class="line"><span class="comment">// perform some operations without re-parsing the JSON Pointer</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *val = <a class="code hl_function" href="yyjson_8h.html#a6031b6b35b06127f3fa2278be67c29ea">yyjson_mut_doc_ptr_getx</a>(doc, <span class="stringliteral">&quot;/b/0&quot;</span>, 4, &amp;ctx, &amp;err);</div>
<div class="line"><span class="keywordflow">if</span> (<a class="code hl_function" href="yyjson_8h.html#a17fda97923bb434d4214c56534586606">yyjson_mut_is_null</a>(val)) <a class="code hl_function" href="yyjson_8h.html#a92d8ec53e4cf8426288d86868dc89e09">yyjson_ptr_ctx_remove</a>(&amp;ctx);</div>
<div class="line"><span class="comment">// now: {&quot;a&quot;:0,&quot;b&quot;:[2,3]}</span></div>
<div class="ttc" id="ayyjson_8h_html_a17fda97923bb434d4214c56534586606"><div class="ttname"><a href="yyjson_8h.html#a17fda97923bb434d4214c56534586606">yyjson_mut_is_null</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_mut_is_null(yyjson_mut_val *val)</div><div class="ttdef"><b>Definition</b> yyjson.h:5720</div></div>
<div class="ttc" id="ayyjson_8h_html_a92d8ec53e4cf8426288d86868dc89e09"><div class="ttname"><a href="yyjson_8h.html#a92d8ec53e4cf8426288d86868dc89e09">yyjson_ptr_ctx_remove</a></div><div class="ttdeci">yyjson_api_inline bool yyjson_ptr_ctx_remove(yyjson_ptr_ctx *ctx)</div><div class="ttdef"><b>Definition</b> yyjson.h:7991</div></div>
</div><!-- fragment --><h2><a class="anchor" id="json-patch"></a>
JSON Patch</h2>
<p>The library supports JSON Patch (RFC 6902). Specification and example: <a href="https://tools.ietf.org/html/rfc6902">https://tools.ietf.org/html/rfc6902</a> </p><div class="fragment"><div class="line"><span class="comment">// Creates and returns a patched JSON value.</span></div>
<div class="line"><span class="comment">// Returns NULL if the patch could not be applied.</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a2d0864410efdd15e4591fecc0b4c082c">yyjson_patch</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc,</div>
<div class="line">                             <a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *orig,</div>
<div class="line">                             <a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *patch,</div>
<div class="line">                             <a class="code hl_struct" href="yyjson_8h.html#structyyjson__patch__err">yyjson_patch_err</a> *err);</div>
<div class="line"> </div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#ad4cca957150bd6f19fa12a4f907dffee">yyjson_mut_patch</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc,</div>
<div class="line">                                 <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *orig,</div>
<div class="line">                                 <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *patch,</div>
<div class="line">                                 <a class="code hl_struct" href="yyjson_8h.html#structyyjson__patch__err">yyjson_patch_err</a> *err);</div>
<div class="ttc" id="ayyjson_8h_html_a2d0864410efdd15e4591fecc0b4c082c"><div class="ttname"><a href="yyjson_8h.html#a2d0864410efdd15e4591fecc0b4c082c">yyjson_patch</a></div><div class="ttdeci">yyjson_api yyjson_mut_val * yyjson_patch(yyjson_mut_doc *doc, yyjson_val *orig, yyjson_val *patch, yyjson_patch_err *err)</div></div>
<div class="ttc" id="ayyjson_8h_html_ad4cca957150bd6f19fa12a4f907dffee"><div class="ttname"><a href="yyjson_8h.html#ad4cca957150bd6f19fa12a4f907dffee">yyjson_mut_patch</a></div><div class="ttdeci">yyjson_api yyjson_mut_val * yyjson_mut_patch(yyjson_mut_doc *doc, yyjson_mut_val *orig, yyjson_mut_val *patch, yyjson_patch_err *err)</div></div>
<div class="ttc" id="ayyjson_8h_html_structyyjson__patch__err"><div class="ttname"><a href="yyjson_8h.html#structyyjson__patch__err">yyjson_patch_err</a></div><div class="ttdef"><b>Definition</b> yyjson.h:4680</div></div>
</div><!-- fragment --><h2><a class="anchor" id="json-merge-patch"></a>
JSON Merge Patch</h2>
<p>The library supports JSON Merge Patch (RFC 7386). Specification and example: <a href="https://tools.ietf.org/html/rfc7386">https://tools.ietf.org/html/rfc7386</a> </p><div class="fragment"><div class="line"><span class="comment">// Creates and returns a merge-patched JSON value.</span></div>
<div class="line"><span class="comment">// Returns NULL if the patch could not be applied.</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#a9026faa4e022392c28e8f9afa553362f">yyjson_merge_patch</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc,</div>
<div class="line">                                   <a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *orig,</div>
<div class="line">                                   <a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *patch);</div>
<div class="line"> </div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *<a class="code hl_function" href="yyjson_8h.html#aad64266ebfbdd2a9627050cf1f3f48d7">yyjson_mut_merge_patch</a>(<a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a> *doc,</div>
<div class="line">                                       <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *orig,</div>
<div class="line">                                       <a class="code hl_struct" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a> *patch);</div>
<div class="ttc" id="ayyjson_8h_html_a9026faa4e022392c28e8f9afa553362f"><div class="ttname"><a href="yyjson_8h.html#a9026faa4e022392c28e8f9afa553362f">yyjson_merge_patch</a></div><div class="ttdeci">yyjson_api yyjson_mut_val * yyjson_merge_patch(yyjson_mut_doc *doc, yyjson_val *orig, yyjson_val *patch)</div></div>
<div class="ttc" id="ayyjson_8h_html_aad64266ebfbdd2a9627050cf1f3f48d7"><div class="ttname"><a href="yyjson_8h.html#aad64266ebfbdd2a9627050cf1f3f48d7">yyjson_mut_merge_patch</a></div><div class="ttdeci">yyjson_api yyjson_mut_val * yyjson_mut_merge_patch(yyjson_mut_doc *doc, yyjson_mut_val *orig, yyjson_mut_val *patch)</div></div>
</div><!-- fragment --><hr  />
 <h1><a class="anchor" id="number-processing"></a>
Number Processing</h1>
<h2><a class="anchor" id="number-reader"></a>
Number reader</h2>
<p>The library has a built-in high-performance number reader,<br  />
 it will read numbers according to these rules by default:<br  />
</p>
<ul>
<li>Positive integers are read as <code>uint64_t</code>. If an overflow occurs, it is converted to <code>double</code>.</li>
<li>Negative integers are read as <code>int64_t</code>. If an overflow occurs, it is converted to <code>double</code>.</li>
<li>Floating-point numbers are read as <code>double</code> with correct rounding.</li>
<li>If a <code>double</code> number overflow (reaches infinity), an error is reported.</li>
<li>If a number does not conform to the <a href="https://www.json.org">JSON</a> standard, an error is reported.</li>
</ul>
<p>There are 3 flags that can be used to adjust the number parsing strategy:</p>
<ul>
<li><code>YYJSON_READ_ALLOW_INF_AND_NAN</code>: read nan/inf number or literal as <code>double</code> (non-standard).</li>
<li><code>YYJSON_READ_NUMBER_AS_RAW</code>: read all numbers as raw strings without parsing.</li>
<li><code>YYJSON_READ_BIGNUM_AS_RAW</code>: read big numbers (overflow or infinity) as raw strings without parsing.</li>
</ul>
<p>See the <code>Reader flag</code> section for more details.</p>
<h2><a class="anchor" id="number-writer"></a>
Number writer</h2>
<p>The library has a built-in high-performance number writer,<br  />
 it will write numbers according to these rules by default:<br  />
</p>
<ul>
<li>Positive integers are written without a sign.</li>
<li>Negative integers are written with a negative sign.</li>
<li>Floating-point numbers are written using the <a href="https://www.ecma-international.org/ecma-262/11.0/index.html#sec-numeric-types-number-tostring">ECMAScript format</a>, with the following modifications:<ul>
<li>If the number is <code>Infinity</code> or <code>NaN</code>, an error is reported.</li>
<li>The negative sign of <code>-0.0</code> is preserved to maintain input information.</li>
<li>The positive sign in the exponent part is removed.</li>
</ul>
</li>
<li>The floating-point number writer will generate the shortest correctly rounded decimal representation.</li>
</ul>
<p>There are several flags that can be used to adjust the number writing strategy:</p>
<ul>
<li><code>YYJSON_WRITE_ALLOW_INF_AND_NAN</code> writes inf/nan numbers as <code>Infinity</code> and <code>NaN</code> literals without error (non-standard).</li>
<li><code>YYJSON_WRITE_INF_AND_NAN_AS_NULL</code> writes inf/nan numbers as <code>null</code> literal.</li>
<li><code>YYJSON_WRITE_FP_TO_FLOAT</code> writes real numbers as <code>float</code> instead of <code>double</code>.</li>
<li><code><a class="el" href="yyjson_8h.html#aa6456ada04bdbe304c1f3fb14e309ac6">YYJSON_WRITE_FP_TO_FIXED(prec)</a></code> writes real numbers using fixed-point notation.</li>
</ul>
<p>See the <code>Writer flag</code> section for more details.</p>
<p>There are also some helper functions to control the output format of individual values:</p><ul>
<li><code><a class="el" href="yyjson_8h.html#a0705e92b9d45c609be958ec7f2351900">yyjson_set_fp_to_float(yyjson_val *val, bool fpt)</a></code> and <code><a class="el" href="yyjson_8h.html#a1568c53a68914a5660a50490232737ac">yyjson_mut_set_fp_to_float(yyjson_mut_val *val, bool flt)</a></code> write this real number with <code>float</code> or <code>double</code> precision.</li>
<li><code><a class="el" href="yyjson_8h.html#a1f72379c8ef022cbe6ad815101c8acec">yyjson_set_fp_to_fixed(yyjson_val *val, int prec)</a></code> and <code><a class="el" href="yyjson_8h.html#a0c58c31c80202d83c1c2d3bd69e3bf72">yyjson_mut_set_fp_to_fixed(yyjson_mut_val *val, int prec)</a></code> write this real number using fixed-point notation, the prec should be in the range of 1 to 15.</li>
</ul>
<h2><a class="anchor" id="number-conversion-function"></a>
Number conversion function</h2>
<p>There are also two utility functions provide direct access to the library's internal number conversion logic. <br  />
 They are intended for standalone use and typically do not allocate memory. </p><div class="fragment"><div class="line"><span class="comment">// parse a number from strin</span></div>
<div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code hl_function" href="yyjson_8h.html#a2b7dfa8495fb1d839e6294f2e7c4b58a">yyjson_read_number</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *dat,</div>
<div class="line">                               <a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val,</div>
<div class="line">                               <a class="code hl_typedef" href="yyjson_8h.html#a36af676813028c1360e8b343768f0e81">yyjson_read_flag</a> flg,</div>
<div class="line">                               <span class="keyword">const</span> <a class="code hl_struct" href="yyjson_8h.html#structyyjson__alc">yyjson_alc</a> *alc,</div>
<div class="line">                               <a class="code hl_struct" href="yyjson_8h.html#structyyjson__read__err">yyjson_read_err</a> *err);</div>
<div class="line"><span class="comment">// write a number to string</span></div>
<div class="line"><span class="keywordtype">char</span> *<a class="code hl_function" href="yyjson_8h.html#a26250087651ed3282ef31a27a0673333">yyjson_write_number</a>(<span class="keyword">const</span> <a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val, <span class="keywordtype">char</span> *buf);</div>
<div class="ttc" id="ayyjson_8h_html_a26250087651ed3282ef31a27a0673333"><div class="ttname"><a href="yyjson_8h.html#a26250087651ed3282ef31a27a0673333">yyjson_write_number</a></div><div class="ttdeci">yyjson_api char * yyjson_write_number(const yyjson_val *val, char *buf)</div></div>
<div class="ttc" id="ayyjson_8h_html_a2b7dfa8495fb1d839e6294f2e7c4b58a"><div class="ttname"><a href="yyjson_8h.html#a2b7dfa8495fb1d839e6294f2e7c4b58a">yyjson_read_number</a></div><div class="ttdeci">yyjson_api const char * yyjson_read_number(const char *dat, yyjson_val *val, yyjson_read_flag flg, const yyjson_alc *alc, yyjson_read_err *err)</div></div>
</div><!-- fragment --><h1><a class="anchor" id="text-processing"></a>
Text Processing</h1>
<h2><a class="anchor" id="character-encoding"></a>
Character Encoding</h2>
<p>By default, this library supports UTF-8 encoding without a BOM, as specified in <a href="https://datatracker.ietf.org/doc/html/rfc8259#section-8.1">RFC 8259</a>:</p>
<blockquote class="doxtable">
<p>JSON text exchanged between systems that are not part of a closed ecosystem MUST be encoded using UTF-8. Implementations MUST NOT add a byte order mark (U+FEFF) to the beginning of a networked-transmitted JSON text. </p>
</blockquote>
<p>This library performs strict UTF-8 encoding validation on input strings by default. If an invalid character is encountered, an error will be reported.</p>
<p>To allow a BOM, use the <code>YYJSON_READ_ALLOW_BOM</code> or <code>YYJSON_READ_ALLOW_EXT_WHITESPACE</code> flags.</p>
<p>To allow invalid Unicode encoding, use the <code>YYJSON_READ_ALLOW_INVALID_UNICODE</code> and <code>YYJSON_WRITE_ALLOW_INVALID_UNICODE</code> flags. <b>Note:</b> Enabling these flags may result in yyjson producing values that contain invalid characters, which could be processed by other code and potentially introduce security risks.</p>
<p>To mark a string as not requiring escaping during JSON writing, use <code><a class="el" href="yyjson_8h.html#a44386e6e1084aaea376238723bd11d74">yyjson_set_str_noesc(yyjson_val *val, bool noesc)</a></code> or <code><a class="el" href="yyjson_8h.html#acaf2da602f21785dbacc66661f89a570">yyjson_mut_set_str_noesc(yyjson_mut_val *val, bool noesc)</a></code>. This can improve string-writing performance and preserve the original string bytes.</p>
<h2><a class="anchor" id="nul-character"></a>
NUL Character</h2>
<p>This library supports the <code>NUL</code> character (also known as the <code>null terminator</code>, or Unicode <code>U+0000</code>, ASCII <code>\0</code>) inside strings.</p>
<p>When reading JSON, <code>\u0000</code> will be unescaped to <code>NUL</code> character. If a string contains the <code>NUL</code> character, the length obtained with <code>strlen()</code> will be inaccurate, and you should use <code><a class="el" href="yyjson_8h.html#ae4b5e4edc9713d9f48e2a6750ad5ebff">yyjson_get_len()</a></code> to get the actual length.</p>
<p>When building JSON, the input string is treated as null-terminated by default. If you need to pass in a string that contains the <code>NUL</code> character, you should use the API with the <code>n</code> suffix and provide the actual length of the string.</p>
<p>For example: </p><div class="fragment"><div class="line"><span class="comment">// null-terminated string</span></div>
<div class="line"><a class="code hl_function" href="yyjson_8h.html#ae8d7e4c75adb1b9adb2246165491a4a3">yyjson_mut_str</a>(doc, str);</div>
<div class="line"><a class="code hl_function" href="yyjson_8h.html#a1e8a4dea2e9e9248acde14c664ab702b">yyjson_obj_get</a>(obj, str);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// any string, with or without null terminator</span></div>
<div class="line"><a class="code hl_function" href="yyjson_8h.html#a13c39f37c6936907c266ba9c076dd741">yyjson_mut_strn</a>(doc, str, len);</div>
<div class="line"><a class="code hl_function" href="yyjson_8h.html#a2936ca2492ae8cdcdf0435f5259ff854">yyjson_obj_getn</a>(obj, str, len);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// C++ string</span></div>
<div class="line">std::string sstr = ...;</div>
<div class="line"><a class="code hl_function" href="yyjson_8h.html#a2936ca2492ae8cdcdf0435f5259ff854">yyjson_obj_getn</a>(obj, sstr.data(), sstr.length());</div>
</div><!-- fragment --><h1><a class="anchor" id="memory-allocator"></a>
Memory Allocator</h1>
<p>The library does not directly call libc's memory allocation functions (malloc/realloc/free). Instead, when memory allocation is required, yyjson's API takes a parameter named <code>alc</code> that allows the caller to pass in an allocator. If the <code>alc</code> is NULL, yyjson will use the default memory allocator, which is a simple wrapper of libc's functions.</p>
<p>Using a custom memory allocator allows you to have more control over memory allocation, here are a few examples:</p>
<h2><a class="anchor" id="single-allocator-for-multiple-json"></a>
Single allocator for multiple JSON</h2>
<p>If you need to parse multiple small JSON one by one, you can use a single allocator to avoid multiple memory allocations.</p>
<p>Sample code: </p><div class="fragment"><div class="line"><span class="comment">// max data size for single JSON</span></div>
<div class="line"><span class="keywordtype">size_t</span> max_json_size = 64 * 1024;</div>
<div class="line"><span class="comment">// calculate the max memory usage for a single JSON</span></div>
<div class="line"><span class="keywordtype">size_t</span> buf_size = <a class="code hl_function" href="yyjson_8h.html#ae511cac592355c2f60f170402b9d8dbf">yyjson_read_max_memory_usage</a>(max_json_size, 0);</div>
<div class="line"><span class="comment">// create a buffer for allocator</span></div>
<div class="line"><span class="keywordtype">void</span> *buf = malloc(buf_size);</div>
<div class="line"><span class="comment">// setup the allocator with buffer</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__alc">yyjson_alc</a> alc;</div>
<div class="line"><a class="code hl_function" href="yyjson_8h.html#a6068c4293a2b35493b18421b9afbd3d5">yyjson_alc_pool_init</a>(&amp;alc, buf, buf_size);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// read multiple JSON using one allocator</span></div>
<div class="line"><span class="keywordflow">for</span>(<span class="keywordtype">int</span> i = 0, i &lt; your_json_file_count; i++) {</div>
<div class="line">    <span class="keyword">const</span> <span class="keywordtype">char</span> *your_json_file_path = ...;</div>
<div class="line">    <a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *doc = <a class="code hl_function" href="yyjson_8h.html#a605ac08b083fb65331d7fa5eb5d32225">yyjson_read_file</a>(your_json_file_path, 0, &amp;alc, NULL);</div>
<div class="line">    ...</div>
<div class="line">    <a class="code hl_function" href="yyjson_8h.html#adad98bd766cf52d99f2c54dcb120786d">yyjson_doc_free</a>(doc);</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="comment">// free the buffer</span></div>
<div class="line">free(buf);</div>
<div class="ttc" id="ayyjson_8h_html_ae511cac592355c2f60f170402b9d8dbf"><div class="ttname"><a href="yyjson_8h.html#ae511cac592355c2f60f170402b9d8dbf">yyjson_read_max_memory_usage</a></div><div class="ttdeci">yyjson_api_inline size_t yyjson_read_max_memory_usage(size_t len, yyjson_read_flag flg)</div><div class="ttdef"><b>Definition</b> yyjson.h:1090</div></div>
</div><!-- fragment --><p>If you are not sure about the amount of memory required to process JSON, you can use the dynamic allocator. </p><div class="fragment"><div class="line"><span class="comment">// create a dynamic allocator</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__alc">yyjson_alc</a> *alc = <a class="code hl_function" href="yyjson_8h.html#a6a90ae91b82c2e8d6665a28a691eee18">yyjson_alc_dyn_new</a>();</div>
<div class="line"> </div>
<div class="line"><span class="comment">// read multiple JSON using one allocator</span></div>
<div class="line"><span class="keywordflow">for</span>(<span class="keywordtype">int</span> i = 0, i &lt; your_json_file_count; i++) {</div>
<div class="line">    <span class="keyword">const</span> <span class="keywordtype">char</span> *your_json_file_path = ...;</div>
<div class="line">    <a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *doc = <a class="code hl_function" href="yyjson_8h.html#a605ac08b083fb65331d7fa5eb5d32225">yyjson_read_file</a>(your_json_file_path, 0, alc, NULL);</div>
<div class="line">    ...</div>
<div class="line">    <a class="code hl_function" href="yyjson_8h.html#adad98bd766cf52d99f2c54dcb120786d">yyjson_doc_free</a>(doc);</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="comment">// free the allocator</span></div>
<div class="line"><a class="code hl_function" href="yyjson_8h.html#aaa9b7978e7b40e6d5d8d1cb3da0568d6">yyjson_alc_dyn_free</a>(alc);</div>
<div class="ttc" id="ayyjson_8h_html_a6a90ae91b82c2e8d6665a28a691eee18"><div class="ttname"><a href="yyjson_8h.html#a6a90ae91b82c2e8d6665a28a691eee18">yyjson_alc_dyn_new</a></div><div class="ttdeci">yyjson_api yyjson_alc * yyjson_alc_dyn_new(void)</div></div>
<div class="ttc" id="ayyjson_8h_html_aaa9b7978e7b40e6d5d8d1cb3da0568d6"><div class="ttname"><a href="yyjson_8h.html#aaa9b7978e7b40e6d5d8d1cb3da0568d6">yyjson_alc_dyn_free</a></div><div class="ttdeci">yyjson_api void yyjson_alc_dyn_free(yyjson_alc *alc)</div></div>
</div><!-- fragment --><h2><a class="anchor" id="stack-memory-allocator"></a>
Stack memory allocator</h2>
<p>If the JSON is small enough, you can use stack memory to read or write it.</p>
<p>Sample code: </p><div class="fragment"><div class="line"><span class="keywordtype">char</span> buf[128 * 1024]; <span class="comment">// stack buffer</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__alc">yyjson_alc</a> alc;</div>
<div class="line"><a class="code hl_function" href="yyjson_8h.html#a6068c4293a2b35493b18421b9afbd3d5">yyjson_alc_pool_init</a>(&amp;alc, buf, <span class="keyword">sizeof</span>(buf));</div>
<div class="line"> </div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *doc = <a class="code hl_function" href="yyjson_8h.html#acf234d21f0cb4b7fc89381ef25e9f0a8">yyjson_read_opts</a>(dat, len, 0, &amp;alc, NULL);</div>
<div class="line">...</div>
<div class="line">yyjson_doc_free(doc); <span class="comment">// this is optional, as the memory is on stack</span></div>
</div><!-- fragment --><h2><a class="anchor" id="use-a-third-party-allocator-library"></a>
Use a third-party allocator library</h2>
<p>You can use a third-party high-performance memory allocator for yyjson, such as <a href="https://github.com/jemalloc/jemalloc">jemalloc</a>, <a href="https://github.com/google/tcmalloc">tcmalloc</a>, <a href="https://github.com/microsoft/mimalloc">mimalloc</a>. You can also refer to the following code to implement your own allocator.</p>
<p>Sample code: </p><div class="fragment"><div class="line"><span class="comment">// Use https://github.com/microsoft/mimalloc</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;mimalloc.h&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="comment">// same as malloc(size)</span></div>
<div class="line"><span class="keyword">static</span> <span class="keywordtype">void</span> *priv_malloc(<span class="keywordtype">void</span> *ctx, <span class="keywordtype">size_t</span> size) {</div>
<div class="line">    <span class="keywordflow">return</span> mi_malloc(size);</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="comment">// same as realloc(ptr, size)</span></div>
<div class="line"><span class="comment">// `old_size` is the size of the originally allocated memory</span></div>
<div class="line"><span class="keyword">static</span> <span class="keywordtype">void</span> *priv_realloc(<span class="keywordtype">void</span> *ctx, <span class="keywordtype">void</span> *ptr, <span class="keywordtype">size_t</span> old_size, <span class="keywordtype">size_t</span> size) {</div>
<div class="line">    <span class="keywordflow">return</span> mi_realloc(ptr, size);</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="comment">// same as free(ptr)</span></div>
<div class="line"><span class="keyword">static</span> <span class="keywordtype">void</span> priv_free(<span class="keywordtype">void</span> *ctx, <span class="keywordtype">void</span> *ptr) {</div>
<div class="line">    mi_free(ptr);</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="comment">// the allocator object</span></div>
<div class="line"><span class="keyword">static</span> <span class="keyword">const</span> <a class="code hl_struct" href="yyjson_8h.html#structyyjson__alc">yyjson_alc</a> PRIV_ALC = {</div>
<div class="line">    priv_malloc,</div>
<div class="line">    priv_realloc,</div>
<div class="line">    priv_free,</div>
<div class="line">    NULL <span class="comment">// `ctx` which will be passed into the functions above</span></div>
<div class="line">};</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Read with custom allocator</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *doc = yyjson_doc_read_opts(dat, len, 0, &amp;PRIV_ALC, NULL);</div>
<div class="line">...</div>
<div class="line">yyjson_doc_free(doc);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Write with custom allocator</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__alc">yyjson_alc</a> *alc = &amp;PRIV_ALC;</div>
<div class="line"><span class="keywordtype">char</span> *json = yyjson_doc_write(doc, 0, alc, NULL, NULL);</div>
<div class="line">...</div>
<div class="line">alc-&gt;free(alc-&gt;<a class="code hl_variable" href="yyjson_8h.html#ae9499246c39efd68c206280de1b31f45">ctx</a>, json);</div>
</div><!-- fragment --><h1><a class="anchor" id="stack-memory-usage"></a>
Stack Memory Usage</h1>
<p>Most functions in the library use fixed-size stack memory. This includes functions for JSON reading and writing, as well as JSON Pointer handling.</p>
<p>However, a few functions use recursion and may cause a stack overflow if the object level is too deep. These functions are marked with the following warning in the header file: </p><blockquote class="doxtable">
<dl class="section warning"><dt>Warning</dt><dd>This function is recursive and may cause a stack overflow if the object level is too deep. </dd></dl>
</blockquote>
<h1><a class="anchor" id="null-check"></a>
Null Check</h1>
<p>The library's public APIs perform a <code>null check</code> for every input parameter to prevent crashes.</p>
<p>For example, when reading a JSON, you don't need to perform null checks or type checks on each value: </p><div class="fragment"><div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a> *doc = <a class="code hl_function" href="yyjson_8h.html#aeab3c2a1d86225e5b181fb1bba7587d4">yyjson_read</a>(NULL, 0, 0); <span class="comment">// doc is NULL</span></div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *val = <a class="code hl_function" href="yyjson_8h.html#aa33a13a85b840b3dbc1f8534db2bd8fc">yyjson_doc_get_root</a>(doc); <span class="comment">// val is NULL</span></div>
<div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> *str = <a class="code hl_function" href="yyjson_8h.html#a986e994db00b2749e000af0a4331454c">yyjson_get_str</a>(val); <span class="comment">// str is NULL</span></div>
<div class="line"><span class="keywordflow">if</span> (!str) printf(<span class="stringliteral">&quot;err!&quot;</span>);</div>
<div class="line"><a class="code hl_function" href="yyjson_8h.html#adad98bd766cf52d99f2c54dcb120786d">yyjson_doc_free</a>(doc); <span class="comment">// do nothing</span></div>
</div><!-- fragment --><p>However, if you are certain that a value is non-null and matches the expected type, you can use the <code>unsafe</code> prefix API to avoid the null check.</p>
<p>For example, when iterating over an array or object, the value and key must be non-null: </p><div class="fragment"><div class="line"><span class="keywordtype">size_t</span> idx, max;</div>
<div class="line"><a class="code hl_struct" href="yyjson_8h.html#structyyjson__val">yyjson_val</a> *key, *val;</div>
<div class="line"><a class="code hl_define" href="yyjson_8h.html#a32884e21b899ea5869b12aec02083002">yyjson_obj_foreach</a>(obj, idx, max, key, val) {</div>
<div class="line">    <span class="comment">// this is a valid JSON, so the key must be a valid string</span></div>
<div class="line">    <span class="keywordflow">if</span> (unsafe_yyjson_equals_str(key, <span class="stringliteral">&quot;id&quot;</span>) &amp;&amp;</div>
<div class="line">        unsafe_yyjson_is_uint(val) &amp;&amp;</div>
<div class="line">        unsafe_yyjson_get_uint(val) == 1234) {</div>
<div class="line">        ...</div>
<div class="line">    }</div>
<div class="line">}</div>
</div><!-- fragment --><h1><a class="anchor" id="thread-safety"></a>
Thread Safety</h1>
<p>The library does not use global variables. Therefore, if you can ensure that the input parameters of a function are thread-safe, then the function calls are also thread-safe.<br  />
</p>
<p>In general, <code><a class="el" href="yyjson_8h.html#structyyjson__doc">yyjson_doc</a></code> and <code><a class="el" href="yyjson_8h.html#structyyjson__val">yyjson_val</a></code> are immutable and thread-safe, while <code><a class="el" href="yyjson_8h.html#structyyjson__mut__doc">yyjson_mut_doc</a></code> and <code><a class="el" href="yyjson_8h.html#structyyjson__mut__val">yyjson_mut_val</a></code> are mutable and not thread-safe.</p>
<h1><a class="anchor" id="locale-independence"></a>
Locale Independence</h1>
<p>The library is designed to be locale-independent.</p>
<p>However, there are certain conditions that you should be aware of:</p>
<ol type="1">
<li>You use libc's <code>setlocale()</code> function to change the locale.</li>
<li>Your environment does not adhere the IEEE 754 floating-point standard (e.g. some IBM mainframes), or you explicitly set <code>YYJSON_DISABLE_FAST_FP_CONV</code> during build, in such case yyjson will use <code>strtod()</code> to parse floating-point numbers.</li>
</ol>
<p>If <b>both</b> of these conditions are met, it is recommended to avoid calling <code>setlocale()</code> while another thread is parsing JSON. Otherwise, an error may be returned during JSON floating-point number parsing. </p>
</div></div><!-- contents -->
</div><!-- PageDoc -->
</div><!-- doc-content -->
<!-- HTML footer for doxygen 1.13.2-->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Documentation for <a href="https://github.com/ibireme/yyjson" target="_blank">yyjson</a>, generated by <a href="https://www.doxygen.org/index.html" target="_blank">doxygen</a> 1.13.2 </li>
  </ul>
</div>
</body>
</html>
